glassfish
  1. glassfish
  2. GLASSFISH-20331

[Batch CLI] NPE thrown out when start the domain

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0_b84_RC1
    • Fix Version/s: 4.0_b86_RC2
    • Component/s: batch
    • Labels:
      None
    • Environment:

      Win7

      Description

      The NPE were thrown out on the version of glassfish which I have built at 12/4/2013 in my local platform. Here's my reproduced steps:
      1). asadmin start-domain
      2). asadmin create-instance ins1
      3). asadmin deploy test_sample1.war
      4). asadmin deploy test_sample2.war
      5). asadmin stop-domain
      6). asadmin start-domain

      After step6, the NPE were thrown out as follows:

      [2013-04-17T19:51:55.327+0900] [glassfish 4.0] [WARNING] [NCLS-CORE-00069] [javax.enterprise.system.core] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1366195915327] [levelValue: 900] [[
        Exception while dispatching an event
      java.lang.NullPointerException
      	at org.glassfish.batch.spi.impl.BatchRuntimeHelper.registerIfBatchJobsDirExists(BatchRuntimeHelper.java:178)
      	at org.glassfish.batch.spi.impl.BatchRuntimeHelper.event(BatchRuntimeHelper.java:191)
      	at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
      	at com.sun.enterprise.v3.server.AppServerStartup.postStartupJob(AppServerStartup.java:358)
      	at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:285)
      	at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:179)
      	at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:170)
      	at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
      	at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
      	at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl.start(EmbeddedOSGiGlassFishImpl.java:75)
      	at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
      	at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:71)
      	at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
      	at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
      ]]
      

        Activity

        Hide
        Jeremy_Lv added a comment -

        Here's attached the code of the reproduced web application:
        test_sample1.war

        package com.fujitsu.test.hello;
        
        
        import java.io.IOException;
        import java.io.PrintWriter;
        
        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        
        
        /**
        *
        * @author Jeremy
        */
        @WebServlet(name="MyServlet", urlPatterns={""})
        public class UserServlet extends HttpServlet {
        
           protected void processRequest(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
               response.setContentType("text/html;charset=UTF-8");
               PrintWriter out = response.getWriter();
               try {
                   out.println("<html>");
                   out.println("<head>");
                   out.println("<title>Servlet3.0 HelloWorld</title>");
                   out.println("</head>");
                   out.println("<body>");
                   out.println("<h1>Hello! Servlet3.0 Sample1111111111</h1>");
                   System.out.println("start to execute System.exit()");
                   System.exit(1);
                   System.out.println("System.exit() has been executed");
                   out.println("</body>");
                   out.println("</html>");
                 
               } finally { 
                   out.close();
               }
           } 
        
           @Override
           protected void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
               processRequest(request, response);
           } 
        
           @Override
           protected void doPost(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
               processRequest(request, response);
           }
        
        
           @Override
           public String getServletInfo() {
               return "Short description";
           }
        }
        

        test_sample2.war

        package com.fujitsu.test.hello;
        
        
        import java.io.IOException;
        import java.io.PrintWriter;
        
        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        
        
        /**
        *
        * @author Jeremy
        */
        @WebServlet(name="MyServlet", urlPatterns={""})
        public class UserServlet extends HttpServlet {
        
           protected void processRequest(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
               response.setContentType("text/html;charset=UTF-8");
               PrintWriter out = response.getWriter();
               try {
                   out.println("<html>");
                   out.println("<head>");
                   out.println("<title>Servlet3.0 HelloWorld</title>");
                   out.println("</head>");
                   out.println("<body>");
                   out.println("<h1>Hello! Servlet3.0 Sample22222222222</h1>");
                   System.out.println("start to execute System.exit()");
                   System.out.println("System.exit() has been executed");
                   out.println("</body>");
                   out.println("</html>");
                 
               } finally { 
                   out.close();
               }
           } 
        
           @Override
           protected void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
               processRequest(request, response);
           } 
        
           @Override
           protected void doPost(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
               processRequest(request, response);
           }
        
        
           @Override
           public String getServletInfo() {
               return "Short description";
           }
        }
        

        The only difference between the test_sample1 and test_sample2 is that I add the code of "System.exit(1);" in the test_sample1.

        Show
        Jeremy_Lv added a comment - Here's attached the code of the reproduced web application: test_sample1.war package com.fujitsu.test.hello; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author Jeremy */ @WebServlet(name= "MyServlet" , urlPatterns={""}) public class UserServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType( "text/html;charset=UTF-8" ); PrintWriter out = response.getWriter(); try { out.println( "<html>" ); out.println( "<head>" ); out.println( "<title>Servlet3.0 HelloWorld</title>" ); out.println( "</head>" ); out.println( "<body>" ); out.println( "<h1>Hello! Servlet3.0 Sample1111111111</h1>" ); System .out.println( "start to execute System .exit()" ); System .exit(1); System .out.println( " System .exit() has been executed" ); out.println( "</body>" ); out.println( "</html>" ); } finally { out.close(); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return " Short description" ; } } test_sample2.war package com.fujitsu.test.hello; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author Jeremy */ @WebServlet(name= "MyServlet" , urlPatterns={""}) public class UserServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType( "text/html;charset=UTF-8" ); PrintWriter out = response.getWriter(); try { out.println( "<html>" ); out.println( "<head>" ); out.println( "<title>Servlet3.0 HelloWorld</title>" ); out.println( "</head>" ); out.println( "<body>" ); out.println( "<h1>Hello! Servlet3.0 Sample22222222222</h1>" ); System .out.println( "start to execute System .exit()" ); System .out.println( " System .exit() has been executed" ); out.println( "</body>" ); out.println( "</html>" ); } finally { out.close(); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return " Short description" ; } } The only difference between the test_sample1 and test_sample2 is that I add the code of "System.exit(1);" in the test_sample1.
        Hide
        Jeremy_Lv added a comment -

        If anyone need these two applications, pl. send the mail to me(lvsongping@cn.fujitsu.com).

        Show
        Jeremy_Lv added a comment - If anyone need these two applications, pl. send the mail to me(lvsongping@cn.fujitsu.com).
        Hide
        TangYong added a comment -

        This seemed to be batch module's issue.

        Show
        TangYong added a comment - This seemed to be batch module's issue.
        Hide
        TangYong added a comment -

        Also noting the issue happened on cluster scene.

        Show
        TangYong added a comment - Also noting the issue happened on cluster scene.
        Hide
        Mahesh Kannan added a comment -

        Marking as Batch CLI issue

        Show
        Mahesh Kannan added a comment - Marking as Batch CLI issue
        Hide
        Mahesh Kannan added a comment -

        First of all couldn't reproduce this issue.

        The offending line (@ 178) is as follows:

        ClassLoader cl = moduleInfo.getModuleClassLoader();
        @178 ==> if (cl.getResource("META-INF/batch-jobs") != null)

        { tagNamesRequiringCleanup.add(config.getName() + ":" + applicationInfo.getName()); }

        The only way this could happen is if moduleInfo.getModuleClassLoader(); is null (System class loader). Not sure if apps can be
        deployed using system CL.

        Anyways, I have added a null check to this line as follows:
        ClassLoader cl = moduleInfo.getModuleClassLoader();
        @178 ==> if (cl != null && cl.getResource("META-INF/batch-jobs") != null)

        { tagNamesRequiringCleanup.add(config.getName() + ":" + applicationInfo.getName()); }
        Show
        Mahesh Kannan added a comment - First of all couldn't reproduce this issue. The offending line (@ 178) is as follows: ClassLoader cl = moduleInfo.getModuleClassLoader(); @178 ==> if (cl.getResource("META-INF/batch-jobs") != null) { tagNamesRequiringCleanup.add(config.getName() + ":" + applicationInfo.getName()); } The only way this could happen is if moduleInfo.getModuleClassLoader(); is null (System class loader). Not sure if apps can be deployed using system CL. Anyways, I have added a null check to this line as follows: ClassLoader cl = moduleInfo.getModuleClassLoader(); @178 ==> if (cl != null && cl.getResource("META-INF/batch-jobs") != null) { tagNamesRequiringCleanup.add(config.getName() + ":" + applicationInfo.getName()); }
        Hide
        Jeremy_Lv added a comment -

        Mashech:
        Here's some comments in line:
        1). I will update the source to the latest one and check whether the NPE is still exist.
        2). pl. tell me your mail address so that I can send you these two application and you can reproduce in your platform.
        3). I will also try to add the null check you have pointed out to check whether the issue is still exist.

        Thanks

        -jeremy

        Show
        Jeremy_Lv added a comment - Mashech: Here's some comments in line: 1). I will update the source to the latest one and check whether the NPE is still exist. 2). pl. tell me your mail address so that I can send you these two application and you can reproduce in your platform. 3). I will also try to add the null check you have pointed out to check whether the issue is still exist. Thanks -jeremy
        Hide
        Jeremy_Lv added a comment - - edited

        Sorry about the wrong steps, Here's the exactly steps:
        1. asadmin start-domain
        2. asadmin create-cluster clu1
        3. asadmin create-instance --node localhost-domain1 --cluster clu1 instance1
        4. asadmin deploy --target clu1 test_sample1.war
        5. asadmin deploy --target clu1 test_sample2.war
        6. asadmin stop-domain
        7. asadmin start-domain

        Show
        Jeremy_Lv added a comment - - edited Sorry about the wrong steps, Here's the exactly steps: 1. asadmin start-domain 2. asadmin create-cluster clu1 3. asadmin create-instance --node localhost-domain1 --cluster clu1 instance1 4. asadmin deploy --target clu1 test_sample1.war 5. asadmin deploy --target clu1 test_sample2.war 6. asadmin stop-domain 7. asadmin start-domain
        Hide
        Mahesh Kannan added a comment -

        Thanks for listing the exact steps. Yes, now I can reproduce. Fix will be available in the next build

        Show
        Mahesh Kannan added a comment - Thanks for listing the exact steps. Yes, now I can reproduce. Fix will be available in the next build
        Hide
        Mahesh Kannan added a comment -

        What is the impact on the customer of the bug?
        If any application has been deployed to a cluster / standalone instance, User will see an NPE when the domain is re-started.

        What is the cost/risk of fixing the bug?
        Very low. A few lines.

        Is there an impact on documentation or message strings?
        Yes. Logging a message at Warning Level should any other exception occur.

        Which tests should QA (re)run to verify the fix did not destabilize GlassFish?
        I have run the devtests successfully. The bug submitter was kind enough to do a bunch of tests.
        <from-submitter>
        Here's my steps to tests:
        1). asadmin start-domain
        2). asadmin create-cluster clu1
        3). asadmin create-instance --cluster clu1 --node localhost-domain1 instance1
        4). asadmin deploy test_sample1.war
        5). asadmin deploy --target clu1 test_sample2.war
        6). asadmin stop-domain
        7). asadmin start-domain
        8). asadmin stop-cluster clu1
        9). asadmin start-cluster clu1
        10). asadmin undeploy test_sample1
        11). asadmin undeploy --target clu1 test_sample2

        After all, there's no NPE were thrown out after applied your changes into the latest building source.

        BTW: I have also run the QL tests and all of the tests passed

        QL tests results:

        testng-summary:
        [echo] [testng]
        [echo] [testng] ===============================================
        [echo] [testng] QuickLookTests
        [echo] [testng] Total tests run: 117, Failures: 0, Skips: 0
        [echo] [testng] ===============================================
        [echo] [testng]
        [INFO] Executed tasks
        [INFO] ------------------------------------------------------------------------
        </from-submitter>

        Which is the targeted build of 4.0 for this fix?
        The fix is ready, not sure if it will make it into RC2.

        If this an integration of a new version of a component from another project,
        what are the changes that are being brought in? This might be list of
        Jira issues from that project or a list of revision messages.

        n/a

        Show
        Mahesh Kannan added a comment - What is the impact on the customer of the bug? If any application has been deployed to a cluster / standalone instance, User will see an NPE when the domain is re-started. What is the cost/risk of fixing the bug? Very low. A few lines. Is there an impact on documentation or message strings? Yes. Logging a message at Warning Level should any other exception occur. Which tests should QA (re)run to verify the fix did not destabilize GlassFish? I have run the devtests successfully. The bug submitter was kind enough to do a bunch of tests. <from-submitter> Here's my steps to tests: 1). asadmin start-domain 2). asadmin create-cluster clu1 3). asadmin create-instance --cluster clu1 --node localhost-domain1 instance1 4). asadmin deploy test_sample1.war 5). asadmin deploy --target clu1 test_sample2.war 6). asadmin stop-domain 7). asadmin start-domain 8). asadmin stop-cluster clu1 9). asadmin start-cluster clu1 10). asadmin undeploy test_sample1 11). asadmin undeploy --target clu1 test_sample2 After all, there's no NPE were thrown out after applied your changes into the latest building source. BTW: I have also run the QL tests and all of the tests passed QL tests results: testng-summary: [echo] [testng] [echo] [testng] =============================================== [echo] [testng] QuickLookTests [echo] [testng] Total tests run: 117, Failures: 0, Skips: 0 [echo] [testng] =============================================== [echo] [testng] [INFO] Executed tasks [INFO] ------------------------------------------------------------------------ </from-submitter> Which is the targeted build of 4.0 for this fix? The fix is ready, not sure if it will make it into RC2. If this an integration of a new version of a component from another project, what are the changes that are being brought in? This might be list of Jira issues from that project or a list of revision messages. n/a
        Hide
        Mahesh Kannan added a comment -
        • What is the impact on the customer of the bug?
          Without this fix the user will see an NPE during restart if any apps have been deployed to a cluster)
        • What is the cost/risk of fixing the bug?
          Very low. Just a few lines.
        • Is there an impact on documentation or message strings?
          Yes. A Few message Strings
        • Which tests should QA (re)run to verify the fix did not destabilize GlassFish?
          All batch tests. Although I have run batch devtests and the bug submitter has extensively tested the patch.

        Which is the targeted build of 4.0 for this fix?
        The fix is ready, Most likely in RC2.

        If this an integration of a new version of a component from another project,
        what are the changes that are being brought in? This might be list of
        Jira issues from that project or a list of revision messages.
        N/A

        Show
        Mahesh Kannan added a comment - What is the impact on the customer of the bug? Without this fix the user will see an NPE during restart if any apps have been deployed to a cluster) What is the cost/risk of fixing the bug? Very low. Just a few lines. Is there an impact on documentation or message strings? Yes. A Few message Strings Which tests should QA (re)run to verify the fix did not destabilize GlassFish? All batch tests. Although I have run batch devtests and the bug submitter has extensively tested the patch. Which is the targeted build of 4.0 for this fix? The fix is ready, Most likely in RC2. If this an integration of a new version of a component from another project, what are the changes that are being brought in? This might be list of Jira issues from that project or a list of revision messages. N/A
        Hide
        Tom Mueller added a comment -

        Approved for 4.0.

        Show
        Tom Mueller added a comment - Approved for 4.0.
        Hide
        Mahesh Kannan added a comment -

        svn commit -m "Fix for 20331. QL and Batch devtests passed. Approved by Tom" glassfish-batch-connector/src/main/java/org/glassfish/batch/spi/impl/BatchRuntimeHelper.java

        Sending glassfish-batch-connector/src/main/java/org/glassfish/batch/spi/impl/BatchRuntimeHelper.java
        Transmitting file data .
        Committed revision 61549.

        Show
        Mahesh Kannan added a comment - svn commit -m "Fix for 20331. QL and Batch devtests passed. Approved by Tom" glassfish-batch-connector/src/main/java/org/glassfish/batch/spi/impl/BatchRuntimeHelper.java Sending glassfish-batch-connector/src/main/java/org/glassfish/batch/spi/impl/BatchRuntimeHelper.java Transmitting file data . Committed revision 61549.

          People

          • Assignee:
            Mahesh Kannan
            Reporter:
            Jeremy_Lv
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: