Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5101311

NullPointerException thrown when environment contains strings without `='

    Details

    • Subcomponent:
    • Resolved In Build:
      01
    • CPU:
      sparc
    • OS:
      solaris_8

      Backports

        Description

        Web Server is using a in process VM.Using release b63
        Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)


        During execution of a jsp in webserver with JSK1.5 a NP is thrown in java class ProcessEnvironment.java. The NP is triggered when the jsp does a exec(). The stack trace is as follows:

        javax.servlet.ServletException
                at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
                at _jsps._DateFormat1_jsp._jspService(_DateFormat1_jsp.java:108)
                at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
                at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:675)
                at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:447)
                at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:363)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
                at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:774)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:216)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
                at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
                at com.iplanet.ias.web.WebContainer.service(WebContainer.java:594)
        ----- Root Cause -----
        java.lang.ExceptionInInitializerError
                at java.lang.System.getenv(System.java:844)
                at _jsps._DateFormat1_jsp._jspService(_DateFormat1_jsp.java:76)
                at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
                at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:675)
                at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:447)
                at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:363)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
                at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:774)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:216)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
                at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
                at com.iplanet.ias.web.WebContainer.service(WebContainer.java:594)
        Caused by: java.lang.NullPointerException
                at java.lang.String.<init>(String.java:479)
                at java.lang.ProcessEnvironment$Variable.valueOf(ProcessEnvironment.java:160)
                at java.lang.ProcessEnvironment.<clinit>(ProcessEnvironment.java:60)
                ... 17 more

        I added some print statements to ProcessEnvironment.java and the variable is indeed NULL. Here is the snippet from the log and the source code:

        [10/Sep/2004:14:24:25] warning (10783): CORE3283: stderr: [Loaded java.lang.ProcessEnvironment from /export/uma/s1ws/iplanet/ias/server/work/B1/SunOS5.8_DBG.OBJ/bin/https/jar/jvmbug.jar]
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ.length = 114
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[112] = [B@19bb25a
        [10/Sep/2004:14:24:25] warning (10783): CORE3283: stderr: [Loaded java.lang.ProcessEnvironment$ExternalData from /export/uma/s1ws/iplanet/ias/server/work/B1/SunOS5.8_DBG.OBJ/bin/https/jar/jvmbug.jar]
        [10/Sep/2004:14:24:25] warning (10783): CORE3283: stderr: [Loaded java.lang.ProcessEnvironment$Variable from /export/uma/s1ws/iplanet/ias/server/work/B1/SunOS5.8_DBG.OBJ/bin/https/jar/jvmbug.jar]
        [10/Sep/2004:14:24:25] warning (10783): CORE3283: stderr: [Loaded java.lang.ProcessEnvironment$Value from /export/uma/s1ws/iplanet/ias/server/work/B1/SunOS5.8_DBG.OBJ/bin/https/jar/jvmbug.jar]
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[110] = [B@b9e45a
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[108] = [B@3ef810
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[106] = [B@100363
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[104] = [B@14e8cee
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[102] = [B@67064
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[100] = [B@bcda2d
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[98] = [B@97d01f
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[96] = [B@e0a386
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[94] = [B@feb48
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[92] = [B@11ff436
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[90] = [B@da3a1e
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[88] = [B@11dba45
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[86] = [B@b03be0
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[84] = [B@2af081
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[82] = [B@113a53d
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[80] = [B@c5495e
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[78] = [B@53fb57
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[76] = [B@19a32e0
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[74] = [B@8238f4
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[72] = [B@16925b0
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[70] = [B@297ffb
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[68] = [B@914f6a
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[66] = [B@1f4cbee
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[64] = [B@787d6a
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[62] = [B@71dc3d
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[60] = [B@1326484
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[58] = [B@16546ef
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[56] = [B@1428ea
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[54] = [B@18a49e0
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[52] = [B@1f82982
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[50] = [B@16d2633
        [10/Sep/2004:14:24:25] info (10783): CORE3282: stdout: JVMBUG: environ[48] = null


        final class ProcessEnvironment
        {
            private static final HashMap<Variable,Value> theEnvironment;
            private static final Map<String,String> theUnmodifiableEnvironment;
            static final int MIN_NAME_LENGTH = 0;

            static {
                // We cache the C environment. This means that subsequent calls
                // to putenv/setenv from C will not be visible from Java code.
                byte[][] environ = environ();
                theEnvironment = new HashMap<Variable,Value>(environ.length/2 + 3);
                // Read environment variables back to front,
                // so that earlier variables override later ones.
                System.out.println("JVMBUG: environ.length = "+environ.length);
                for (int i = environ.length-1; i > 0; i-=2) {
                    System.out.println("JVMBUG: environ["+(i-1)+"] = "+environ[i-1]);
                    theEnvironment.put(Variable.valueOf(environ[i-1]),
                                       Value.valueOf(environ[i]));
                }

                theUnmodifiableEnvironment
                    = Collections.unmodifiableMap
                    (new StringEnvironment(theEnvironment));
            }

        To reproduce the problem in the webserver env [please call me X15722 if you need help with this]. I was unable to reproduce the bug in a simple test case.
        1. Download webserver from /net/redbuild.red.iplanet.com/export/builds/webserver/ES6.1sp2/build/ships/P20040407_GC.1/greenaway_SunOS2.8
        2. Install the webserver in <install_root>
        3. Change the JDK location in <install_root>/bin/https/jdk [which in 1.4] to 1.5 using a softlink
        4. Save the attached jsp file at <install_root>/docs/
        5. cd to <install_root>/https-<machine-name>
        6 type command ./start
        7. Using the browser access the jsp using command
        http://localhost:&lt;port_number&gt;/Dateformat1.jsp

        Where port_number is the port that you specified for the instance during the instllation.
        The browser will report an error. You can check the log at <install_root>/https-<machine_name>/logs




        ###@###.### 2004-09-13
        ###@###.### 2004-09-13

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  martin Martin Buchholz
                  Reporter:
                  usabada Uma Sabada
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: