8 Replies Latest reply on Feb 1, 2012 2:17 PM by Jeremy Whiting

    NameNotBoundException during classloading in deployed servlet doGet.

    Jeremy Whiting Expert

      Hi,

      I am seeing a NameNotBoundException in AS7 7.1.0.Final (built from master) during a servlet GET method request. In the method a JNDI lookup is being made when a class is being loaded. I wanted to test two situations during classloading

       

      a) a lookup in a static initialisation block

       

      b) in the constructor of an object

       

      I have created a sample application. The test application shows a NameNotBoundException is thrown and displayed in the console during class loading for a) and b). The servlets have been configured with the following paths.

       

      http://f16lite:8080/envEntryLookupWeb/staticinitlookup

      http://f16lite:8080/envEntryLookupWeb/constructorlookup

       

       

      By the way. This is similar to but not identical to

       

      https://issues.jboss.org/browse/AS7-2961

       

      Shall I raise a JIRA ?

       

      Jeremy

       

      console output

      a)

      16:00:26,291 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1) javax.naming.NameNotFoundException: env/supplier.payloadsize.min -- service jboss.naming.context.java.module.envEntryLookupWeb.envEntryLookupWeb.env."supplier.payloadsize.min"

      16:00:26,291 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:97)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at javax.naming.InitialContext.lookup(InitialContext.java:409)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.performance.jndi.test.lookup.Constructor.<init>(Constructor.java:46)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.performance.jndi.test.servlet.ConstructorLookup.doGet(ConstructorLookup.java:33)

      16:00:26,292 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

      16:00:26,293 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      16:00:26,293 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      16:00:26,293 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      16:00:26,293 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      16:00:26,293 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      16:00:26,293 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626)

      16:00:26,294 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033)

      16:00:26,295 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at java.lang.Thread.run(Thread.java:679)

       

      b)

       

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1) javax.naming.NameNotFoundException: env/supplier.payloadsize.min -- service jboss.naming.context.java.module.envEntryLookupWeb.envEntryLookupWeb.env."supplier.payloadsize.min"

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:97)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at javax.naming.InitialContext.lookup(InitialContext.java:409)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.performance.jndi.test.lookup.StaticInit.<clinit>(StaticInit.java:44)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.performance.jndi.test.servlet.StaticInitLookup.doGet(StaticInitLookup.java:28)

      16:00:30,136 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

      16:00:30,137 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      16:00:30,137 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      16:00:30,137 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      16:00:30,137 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      16:00:30,137 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      16:00:30,137 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)

      16:00:30,138 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      16:00:30,138 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      16:00:30,138 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      16:00:30,138 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

      16:00:30,138 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897)

      16:00:30,139 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626)

      16:00:30,139 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033)

      16:00:30,139 ERROR [stderr] (http-f16lite-10.42.43.1-8080-1)     at java.lang.Thread.run(Thread.java:679)

        • 1. Re: NameNotBoundException during classloading in deployed servlet doGet.
          jaikiran pai Master

          Can you post the relevant code which includes the servlet and also the class that does this lookup?

          • 2. Re: NameNotBoundException during classloading in deployed servlet doGet.
            Jeremy Whiting Expert

            Hi Jaikiran,

            Sure, here are some snippits of code.

             

             

            ------ deployment descriptor

              <env-entry>

                        <description>This entry should be bound to the

                        java comp namespace.</description>

                        <env-entry-name>supplier.payloadsize.min</env-entry-name>

                        <env-entry-type>java.lang.Integer</env-entry-type>

                        <env-entry-value>32</env-entry-value>

                  </env-entry>

                  <env-entry>

                        <description>This env entry is to set the thread keep alive time (in seconds) for threads in the delivery scheduler thread pool </description>

                        <env-entry-name>supplier.payloadsize.max</env-entry-name>

                        <env-entry-type>java.lang.Integer</env-entry-type>

                        <env-entry-value>64</env-entry-value>

                  </env-entry>

            </web-app>

             

            ----- servlet a

            @Override

               protected void doGet(HttpServletRequest request,

                     HttpServletResponse response) throws ServletException, IOException

               {

                  /* this will call the static init block, if the block threw an exception

                   * it will appear as a stack trace in the err print stream */

                  StaticInit si = new StaticInit();

             

             

            ------ object a

            public class StaticInit {

            public static int NET_SEGMENT_SIZE_MIN = -1;

               public static int NET_SEGMENT_SIZE_MAX = -1;

               static

               {

                  try

                  {

                     Context ic = new InitialContext();

                     NET_SEGMENT_SIZE_MIN = ((Integer)ic.

                             lookup("java:comp/env/supplier.payloadsize.min")).

                          intValue();

                     NET_SEGMENT_SIZE_MAX = ((Integer)ic.

                          lookup("java:comp/env/supplier.payloadsize.max")).

                                intValue();

                  }

                  catch(NamingException ex)

                  {

                        ex.printStackTrace();

                  }

               }

             

            ----- servlet b

             

            public class ConstructorLookup extends HttpServlet{

            @Override

               protected void doGet(HttpServletRequest request, HttpServletResponse

                     response) throws ServletException, IOException

               {

                  boolean isSuccess = false; //presumed fail

                 

                  try

                  {

                     /* Construct the object that will perform jndi lookup in the

                      * constructor. */

                     new Constructor();

             

            ------ object b

             

            public class Constructor {

             

               public static int NET_SEGMENT_SIZE_MIN = -1;

               public static int NET_SEGMENT_SIZE_MAX = -1;

              

               /**

                * Perform a jndi lookup

                */

               public Constructor() throws NamingException, NameNotFoundException{

                  Context ic = new InitialContext();

                  NET_SEGMENT_SIZE_MIN = ((Integer)ic.

                          lookup("java:comp/env/supplier.payloadsize.min")).

                          intValue();

                  NET_SEGMENT_SIZE_MAX = ((Integer)ic.

                          lookup("java:comp/env/supplier.payloadsize.max")).

                  intValue();

             

            Regards,

            Jeremy

            • 3. Re: NameNotBoundException during classloading in deployed servlet doGet.
              jaikiran pai Master

              That looks fine to me. Where in the deployment is the deployment descriptor located and what's its name. Can you post the output of

               

              jar -tf envEntryLookupWeb.war

               

              assuming envEntryLookupWeb.war is name of your deployment?

              • 4. Re: NameNotBoundException during classloading in deployed servlet doGet.
                Jeremy Whiting Expert

                Hi Jirikan,

                This is a web application called envEntryLookupWeb.war and the deployment descriptor is web.xml in the WEB-INF directory.

                 

                $ jar -tf envEntryLookupWeb.war

                META-INF/

                META-INF/MANIFEST.MF

                WEB-INF/

                WEB-INF/classes/

                WEB-INF/classes/org/

                WEB-INF/classes/org/jboss/

                WEB-INF/classes/org/jboss/performance/

                WEB-INF/classes/org/jboss/performance/jndi/

                WEB-INF/classes/org/jboss/performance/jndi/test/

                WEB-INF/classes/org/jboss/performance/jndi/test/servlet/

                WEB-INF/classes/org/jboss/performance/jndi/test/lookup/

                web.xml

                WEB-INF/classes/org/jboss/performance/jndi/test/servlet/ConstructorLookup.class

                WEB-INF/classes/org/jboss/performance/jndi/test/servlet/StaticInitLookup.class

                WEB-INF/classes/org/jboss/performance/jndi/test/lookup/Constructor.class

                WEB-INF/classes/org/jboss/performance/jndi/test/lookup/StaticInit.class

                META-INF/maven/

                META-INF/maven/envEntryLookupWeb/

                META-INF/maven/envEntryLookupWeb/envEntryLookupWeb/

                META-INF/maven/envEntryLookupWeb/envEntryLookupWeb/pom.xml

                META-INF/maven/envEntryLookupWeb/envEntryLookupWeb/pom.properties

                 

                Regards,

                Jeremy

                • 5. Re: NameNotBoundException during classloading in deployed servlet doGet.
                  jaikiran pai Master

                  From that output it appears that the web.xml is not in the WEB-INF folder. That explains why the env-entries aren't bound.

                  • 6. Re: NameNotBoundException during classloading in deployed servlet doGet.
                    Jeremy Whiting Expert

                    Yes you are right. My sample application did not have the file in the correct directory. Indeed when it is in the correct one the servlet calls succeed. The JNDI lookups both work now. Thank you for spotting that mistake.

                     

                    But, my sample application does not replicate the original application exactly. I will go back and change the sample to replicate the original to use a Web Service rather than the Servlet.

                     

                    Regards,

                    Jeremy

                    • 7. Re: NameNotBoundException during classloading in deployed servlet doGet.
                      Jeremy Whiting Expert

                      Hi,

                      I have re-written the sample application. This time with identical component types. I have found the two applications differ in the call stacks. When invoking the web service. Also the thread that is processing the request is from a different pool.

                       

                      Can anyone explain why they differ ?

                       

                      Original application

                       

                      Daemon System Thread [default-workqueue-1] (Suspended)
                      DeliveryHandler.<clinit>() line: 90
                      SupplierService.scheduleDelivery(SimplePurchaseOrderType, SupplierService$MessageType, String) line: 159
                      SupplierService.processPurchaseOrder(InlinePurchaseOrderType) line: 73
                      NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
                      NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
                      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
                      Method.invoke(Object, Object...) line: 616
                      InvocationHandlerJAXWS(AbstractInvocationHandlerJSE).invoke(Endpoint, Invocation) line: 111
                      JBossWSInvoker._invokeInternal(Exchange, Object, WrappedMessageContext) line: 169
                      JBossWSInvoker.invoke(Exchange, Object) line: 117
                      ServiceInvokerInterceptor$1.run() line: 58
                      Executors$RunnableAdapter<T>.call() line: 471
                      FutureTask$Sync.innerRun() line: 334
                      ServiceInvokerInterceptor$2(FutureTask<V>).run() line: 166
                      SynchronousExecutor.execute(Runnable) line: 37
                      ServiceInvokerInterceptor.handleMessage(Message) line: 106
                      PhaseInterceptorChain.doIntercept(Message) line: 263
                      PhaseInterceptorChain.resume() line: 232
                      OneWayProcessorInterceptor$1.run() line: 130
                      AutomaticWorkQueueImpl$2.run() line: 353
                      AutomaticWorkQueueImpl(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: 1110
                      ThreadPoolExecutor$Worker.run() line: 603
                      Thread.run() line: 636

                       

                      sample application

                       

                      Daemon Thread [http-burtha02-wireless-10.42.43.55-8080-1] (Suspended (breakpoint at line 43 in StaticInit))
                      StaticInit.<clinit>() line: 43
                      StaticService.doIt() line: 19
                      NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
                      NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
                      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
                      Method.invoke(Object, Object...) line: 616
                      InvocationHandlerJAXWS(AbstractInvocationHandlerJSE).invoke(Endpoint, Invocation) line: 111
                      JBossWSInvoker._invokeInternal(Exchange, Object, WrappedMessageContext) line: 169
                      JBossWSInvoker.invoke(Exchange, Object) line: 117
                      ServiceInvokerInterceptor$1.run() line: 58
                      Executors$RunnableAdapter<T>.call() line: 471
                      FutureTask$Sync.innerRun() line: 334
                      ServiceInvokerInterceptor$2(FutureTask<V>).run() line: 166
                      SynchronousExecutor.execute(Runnable) line: 37
                      ServiceInvokerInterceptor.handleMessage(Message) line: 106
                      PhaseInterceptorChain.doIntercept(Message) line: 263
                      ChainInitiationObserver.onMessage(Message) line: 121
                      ServletDestination(AbstractHTTPDestination).invoke(ServletConfig, ServletContext, HttpServletRequest, HttpServletResponse) line: 206
                      RequestHandlerImpl.handleHttpRequest(Endpoint, HttpServletRequest, HttpServletResponse, ServletContext) line: 91
                      ServletHelper.callRequestHandler(HttpServletRequest, HttpServletResponse, ServletContext, Bus, Endpoint) line: 169
                      CXFServletExt.invoke(HttpServletRequest, HttpServletResponse) line: 87
                      CXFServletExt(AbstractHTTPServlet).handleRequest(HttpServletRequest, HttpServletResponse) line: 184
                      CXFServletExt(AbstractHTTPServlet).doPost(HttpServletRequest, HttpServletResponse) line: 107
                      CXFServletExt(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 754
                      CXFServletExt.service(HttpServletRequest, HttpServletResponse, ServletContext) line: 135
                      WSFServlet.service(HttpServletRequest, HttpServletResponse) line: 140
                      WSFServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 847
                      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 329
                      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 248
                      StandardWrapperValve.invoke(Request, Response) line: 275
                      StandardContextValve.invoke(Request, Response) line: 161
                      SecurityContextAssociationValve.invoke(Request, Response) line: 154
                      StandardHostValve.invoke(Request, Response) line: 155
                      ErrorReportValve.invoke(Request, Response) line: 102
                      StandardEngineValve.invoke(Request, Response) line: 109
                      CoyoteAdapter.service(Request, Response) line: 362
                      Http11AprProcessor.process(long) line: 897
                      Http11AprProtocol$Http11ConnectionHandler.process(long) line: 626
                      AprEndpoint$Worker.run() line: 2033
                      Thread.run() line: 636

                       

                       

                      Regards,

                      Jeremy

                      • 8. Re: NameNotBoundException during classloading in deployed servlet doGet.
                        Jeremy Whiting Expert

                        Hi,

                        I will start a separate discussion. The title is misleading and needs explaining afresh.

                         

                        Regards,

                        Jeremy