glassfish
  1. glassfish
  2. GLASSFISH-17850

Null Pointer exception when export LB Config in Admin Console

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2_b12
    • Fix Version/s: 3.1.2_b13, 4.0
    • Component/s: admin_gui
    • Labels:
      None
    • Environment:

      RHL

      Description

      Steps:

      1) Install/Unzip OGS bits and start-domain
      2) Change Admin login password from empty password to some password
      3) Login Admin console and create a LB with default values.
      4) Open the created LB in console and click export now button in Export Tab

      HTTP status 500 Error with

      java.lang.RuntimeException: java.lang.NullPointerException error message appears in browser.

      Server Logs:
      -----------

      [#|2011-11-30T14:28:47.073+0530|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.com.sun.enterprise.container.common|_ThreadID=26;_ThreadName=Thread-2;|User [] from host localhost.localdomain does not have administration access|#]

      [#|2011-11-30T14:28:47.076+0530|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=20;_ThreadName=Thread-2;|StandardWrapperValve[DownloadServlet]: PWC1406: Servlet.service() for servlet DownloadServlet threw exception
      java.lang.RuntimeException: java.lang.NullPointerException
      at org.glassfish.admingui.common.servlet.LBConfigContentSource.getInputStream(LBConfigContentSource.java:114)
      at org.glassfish.admingui.common.servlet.DownloadServlet.writeContent(DownloadServlet.java:277)
      at org.glassfish.admingui.common.servlet.DownloadServlet.doPost(DownloadServlet.java:174)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:232)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:833)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:730)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1031)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.NullPointerException
      at org.glassfish.admingui.common.util.RestUtil.restRequest(RestUtil.java:199)
      at org.glassfish.admingui.common.util.RestUtil.restRequest(RestUtil.java:149)
      at org.glassfish.admingui.common.servlet.LBConfigContentSource.getInputStream(LBConfigContentSource.java:110)
      ... 29 more

      #]

        Issue Links

          Activity

          Hide
          srinik76 added a comment -

          When admin password is set the rest request is failing in the servlet. So trying to get the rest token from servlet http session and authenticate the rest request.

          checked in the fix into 3.1.2 branch,

          Sending common/src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java
          Transmitting file data .
          Committed revision 51286.

          the svn diff is

          Index: src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java
          ===================================================================
          — src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java (revision 51248)
          +++ src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java (working copy)
          @@ -59,8 +59,18 @@
          import java.util.HashMap;
          import java.util.Map;

          -import javax.servlet.ServletRequest;
          import org.glassfish.admingui.common.util.RestUtil;
          +import com.sun.jersey.api.client.Client;
          +import com.sun.jersey.api.client.ClientResponse;
          +import com.sun.jersey.api.client.WebResource;
          +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
          +import com.sun.jersey.core.util.MultivaluedMapImpl;
          +import javax.servlet.http.HttpServletRequest;
          +import javax.servlet.http.HttpSession;
          +import javax.ws.rs.core.Cookie;
          +import javax.ws.rs.core.MultivaluedMap;
          +import org.glassfish.admingui.common.security.AdminConsoleAuthModule;
          +import org.glassfish.admingui.common.util.RestResponse;

          /**
          *
          @@ -91,7 +101,8 @@
          ctx.setAttribute(DownloadServlet.EXTENSION, "LB-CONFIG");

          // Get appName

          • ServletRequest request = ctx.getServletRequest();
            + HttpServletRequest request = (HttpServletRequest) ctx.getServletRequest();
            + HttpSession session = request.getSession();
            String lbName = request.getParameter("lbName");
            String restUrl = request.getParameter("restUrl");

          @@ -107,7 +118,16 @@
          String slbFile = tempDir + System.getProperty("file.separator") + lbFileName;
          File lbFile = new File(slbFile);
          attrsMap.put("id", slbFile);

          • RestUtil.restRequest( endpoint , attrsMap, "post", null, false);
            + Client client2 = RestUtil.JERSEY_CLIENT;
            + WebResource webResource = client2.resource(endpoint);
            + String token = (String) session.getAttribute(AdminConsoleAuthModule.REST_TOKEN);
            + MultivaluedMap formData = new MultivaluedMapImpl();
            + formData.putSingle("id", slbFile);
            + ClientResponse cr = webResource
            + .cookie(new Cookie("gfresttoken", token))
            + .accept(RestUtil.RESPONSE_TYPE).post(ClientResponse.class, formData);
            + RestResponse rr = RestResponse.getRestResponse(cr);
            + RestUtil.parseResponse(rr, null, endpoint, attrsMap, true, true);
            tmpFile = new FileInputStream(lbFile);
            lbFile.delete();
            } catch (Exception ex) {
          Show
          srinik76 added a comment - When admin password is set the rest request is failing in the servlet. So trying to get the rest token from servlet http session and authenticate the rest request. checked in the fix into 3.1.2 branch, Sending common/src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java Transmitting file data . Committed revision 51286. the svn diff is Index: src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java =================================================================== — src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java (revision 51248) +++ src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java (working copy) @@ -59,8 +59,18 @@ import java.util.HashMap; import java.util.Map; -import javax.servlet.ServletRequest; import org.glassfish.admingui.common.util.RestUtil; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.sun.jersey.core.util.MultivaluedMapImpl; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.core.Cookie; +import javax.ws.rs.core.MultivaluedMap; +import org.glassfish.admingui.common.security.AdminConsoleAuthModule; +import org.glassfish.admingui.common.util.RestResponse; /** * @@ -91,7 +101,8 @@ ctx.setAttribute(DownloadServlet.EXTENSION, "LB-CONFIG"); // Get appName ServletRequest request = ctx.getServletRequest(); + HttpServletRequest request = (HttpServletRequest) ctx.getServletRequest(); + HttpSession session = request.getSession(); String lbName = request.getParameter("lbName"); String restUrl = request.getParameter("restUrl"); @@ -107,7 +118,16 @@ String slbFile = tempDir + System.getProperty("file.separator") + lbFileName; File lbFile = new File(slbFile); attrsMap.put("id", slbFile); RestUtil.restRequest( endpoint , attrsMap, "post", null, false); + Client client2 = RestUtil.JERSEY_CLIENT; + WebResource webResource = client2.resource(endpoint); + String token = (String) session.getAttribute(AdminConsoleAuthModule.REST_TOKEN); + MultivaluedMap formData = new MultivaluedMapImpl(); + formData.putSingle("id", slbFile); + ClientResponse cr = webResource + .cookie(new Cookie("gfresttoken", token)) + .accept(RestUtil.RESPONSE_TYPE).post(ClientResponse.class, formData); + RestResponse rr = RestResponse.getRestResponse(cr); + RestUtil.parseResponse(rr, null, endpoint, attrsMap, true, true); tmpFile = new FileInputStream(lbFile); lbFile.delete(); } catch (Exception ex) {
          Hide
          srinik76 added a comment -

          Checked in the fix into 3.1.2_b13 branch.

          Show
          srinik76 added a comment - Checked in the fix into 3.1.2_b13 branch.
          Hide
          srinik76 added a comment -

          Checked into the trunk.

          Sending common/src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java
          Transmitting file data .
          Committed revision 51287.

          Show
          srinik76 added a comment - Checked into the trunk. Sending common/src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java Transmitting file data . Committed revision 51287.
          Hide
          srinik76 added a comment -

          Need to add the fix version to 4.0

          Show
          srinik76 added a comment - Need to add the fix version to 4.0
          Hide
          srinik76 added a comment -

          Added the fix version to 4.0

          Show
          srinik76 added a comment - Added the fix version to 4.0
          Hide
          srinik76 added a comment -

          Optimizing the fix. Checkin to 3.1.2

          Sending common/src/main/java/org/glassfish/admingui/common/util/RestUtil.java
          Transmitting file data .
          Committed revision 51479.

          Show
          srinik76 added a comment - Optimizing the fix. Checkin to 3.1.2 Sending common/src/main/java/org/glassfish/admingui/common/util/RestUtil.java Transmitting file data . Committed revision 51479.
          Hide
          srinik76 added a comment -

          Sending org/glassfish/admingui/common/servlet/LBConfigContentSource.java
          Transmitting file data .
          Committed revision 51480.

          Show
          srinik76 added a comment - Sending org/glassfish/admingui/common/servlet/LBConfigContentSource.java Transmitting file data . Committed revision 51480.
          Hide
          srinik76 added a comment -

          Sending common/src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java
          Sending common/src/main/java/org/glassfish/admingui/common/util/RestUtil.java
          Transmitting file data ..
          Committed revision 51481.

          Checked into trunk

          Show
          srinik76 added a comment - Sending common/src/main/java/org/glassfish/admingui/common/servlet/LBConfigContentSource.java Sending common/src/main/java/org/glassfish/admingui/common/util/RestUtil.java Transmitting file data .. Committed revision 51481. Checked into trunk

            People

            • Assignee:
              srinik76
              Reporter:
              arunkumar_s
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: