1 2 Previous Next 26 Replies Latest reply on Mar 13, 2014 5:13 PM by Alexander Hartner

    NPE in org.jboss.weld.environment.servlet.Listener

    Alexander Hartner Expert

      When deploying my weld application on tomcat in any other than the default context I am no longer able to log in to my application. I would like to deploy the application into the root "/" context.

       

      When I copy my web application's war file to tomcat/webapps/ROOT.war everything is working as expected. However as soon as I try to add resources I need to specify a context

       

      Working configuration as long as the application WAR is called ROOT.war

      <Host appBase="webapps/weld" name="weld.j2anywhere.com"
        unpackWARs="true" autoDeploy="true"                                         
        xmlValidation="false" xmlNamespaceAware="false">
      </Host>
      
      

       

      However as soon as I introduce a context so that I can add resources for my application I get the exception below:

      <Host appBase="webapps/weld" name="weld.j2anywhere.com"
        unpackWARs="true" autoDeploy="true"                                         
        xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="ROOT">
          <Resources... 
          <Resources... 
        </Context>
      </Host>
      
      

       

      A similar problem occurs when trying to deploy the application under it's proper name insteat of ROOT.war and using the following configuration:

      <Host appBase="webapps/development" name="www.fancywebsite.com" 
            unpackWARs="false" autoDeploy="true"                                         
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="FancyWeb.war" debug="0" priviledged="true">
          <Resource... 
        </Context>
      </Host>
      
      
      

      SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listener

      java.lang.NullPointerException

          at org.jboss.weld.context.AbstractBoundContext.deactivate(AbstractBoundContext.java:71)

          at org.jboss.weld.context.http.HttpRequestContextImpl.deactivate(HttpRequestContextImpl.java:70)

          at org.jboss.weld.servlet.HttpContextLifecycle.requestDestroyed(HttpContextLifecycle.java:179)

          at org.jboss.weld.servlet.WeldInitialListener.requestDestroyed(WeldInitialListener.java:92)

          at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestDestroyed(ForwardingServletListener.java:38)

          at org.apache.catalina.core.StandardContext.fireRequestDestroyEvent(Unknown Source)

          at org.apache.catalina.core.StandardHostValve.invoke(Unknown Source)

          at org.apache.catalina.valves.ErrorReportValve.invoke(Unknown Source)

          at org.apache.catalina.valves.AccessLogValve.invoke(Unknown Source)

          at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)

          at org.apache.catalina.connector.CoyoteAdapter.service(Unknown Source)

          at org.apache.coyote.ajp.AjpAprProcessor.process(Unknown Source)

          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Unknown Source)

          at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(Unknown Source)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

          at java.lang.Thread.run(Thread.java:724)

        • 2. Re: NPE in org.jboss.weld.environment.servlet.Listener
          John Sublette Newbie

          I'm seeing a similar exception for a project that used to work. I'm using Weld-servlet-2.0.4.Final. If the user is not logged in at all, I'm getting that Weld Exception instead of a login failed / or access error message. If the user is logged in, but not granted access, I get the appropriate access denied messages.

           

          I can get around it by removing all of the security-constraint sections in web.xml, or by ensuring the user is logged in.

           

          java.lang.NullPointerException

            org.jboss.weld.context.AbstractBoundContext.deactivate(AbstractBoundContext.java:71)

            org.jboss.weld.context.http.HttpRequestContextImpl.deactivate(HttpRequestContextImpl.java:70)

            org.jboss.weld.servlet.HttpContextLifecycle.requestDestroyed(HttpContextLifecycle.java:183)

            org.jboss.weld.servlet.WeldInitialListener.requestDestroyed(WeldInitialListener.java:92)

            org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestDestroyed(ForwardingServletListener.java:38)

            org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)

            org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:341)

            org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

            org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)

            org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

            org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)

            java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

            java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

            java.lang.Thread.run(Unknown Source)

          • 3. Re: NPE in org.jboss.weld.environment.servlet.Listener
            Jozef Hartinger Master

            Is it also on Tomcat? If so which version? Could you test with 2.1.0.Final and let us know if the issue persists?

            1 of 1 people found this helpful
            • 4. Re: NPE in org.jboss.weld.environment.servlet.Listener
              Alexander Hartner Expert

              I don't see this version available in maven yet. I found a:

              • 2.0.5-Snapshot
              • 2.1.0-Alpha
              • 2.1.0-Beta1
              • 2.1.0-Beta2
              • 2.1.0-CR1

              Which version should I take, or should I wait for the Final release ?

              • 6. Re: NPE in org.jboss.weld.environment.servlet.Listener
                John Sublette Newbie

                Same error with 2.1.0.Final.jar (& Tomcat 7.0.32). The only difference seems to be in the line numbers.

                 

                Oct 29, 2013 10:42:27 AM org.apache.catalina.core.StandardContext fireRequestDestroyEvent

                SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listener

                java.lang.NullPointerException

                at org.jboss.weld.context.AbstractBoundContext.deactivate(AbstractBoundContext.java:71)

                at org.jboss.weld.context.http.HttpRequestContextImpl.deactivate(HttpRequestContextImpl.java:70)

                at org.jboss.weld.servlet.HttpContextLifecycle.requestDestroyed(HttpContextLifecycle.java:225)

                at org.jboss.weld.servlet.WeldInitialListener.requestDestroyed(WeldInitialListener.java:118)

                at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestDestroyed(ForwardingServletListener.java:38)

                at org.apache.catalina.core.StandardContext.fireRequestDestroyEvent(StandardContext.java:5982)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:196)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)

                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)

                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)

                at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

                at java.lang.Thread.run(Thread.java:724)

                • 7. Re: NPE in org.jboss.weld.environment.servlet.Listener
                  Alexander Hartner Expert

                  Yep, still the same issue.

                   

                  Oct 30, 2013 1:43:42 PM org.apache.catalina.core.StandardContext fireRequestDestroyEvent

                  SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listener

                  java.lang.NullPointerException

                      at org.jboss.weld.context.AbstractBoundContext.deactivate(AbstractBoundContext.java:71)

                      at org.jboss.weld.context.http.HttpRequestContextImpl.deactivate(HttpRequestContextImpl.java:70)

                      at org.jboss.weld.servlet.HttpContextLifecycle.requestDestroyed(HttpContextLifecycle.java:225)

                      at org.jboss.weld.servlet.WeldInitialListener.requestDestroyed(WeldInitialListener.java:118)

                      at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestDestroyed(ForwardingServletListener.java:38)

                      at org.apache.catalina.core.StandardContext.fireRequestDestroyEvent(StandardContext.java:6084)

                      at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:426)

                      at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:280)

                      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)

                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)

                      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)

                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

                      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)

                      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

                      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)

                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

                      at java.lang.Thread.run(Thread.java:744)

                  • 8. Re: NPE in org.jboss.weld.environment.servlet.Listener
                    Martin Kouba Master

                    John, Alexander,

                    I cannot reproduce this failure on Tomcat 7.0.26 and Weld 2.1.0.Final. What resources do you define inside the context element? Also it would be great if you could provide some very simple reproducer (app source + server.xml).

                    • 9. Re: NPE in org.jboss.weld.environment.servlet.Listener
                      Alexander Hartner Expert

                      I created a small sample application. The error occurs when you click on the login link.

                      https://www.dropbox.com/s/h85tzy77e4iw0zt/WeldDebug.zip

                      Please let me know what you find. Thanks for taking a look and sorry for having taken so long.

                      • 10. Re: NPE in org.jboss.weld.environment.servlet.Listener
                        Martin Kouba Master

                        Hi Alexander,

                        the server configuration file with context definition is missing. Without this file everything works as expected. Could you provide the configuration as well?

                        • 11. Re: Re: NPE in org.jboss.weld.environment.servlet.Listener
                          Alexander Hartner Expert

                          My bad. I thought I included this in the zip file. The context.xml file contains:

                           

                          <?xml version="1.0" encoding="UTF-8"?>
                          <Context antiJARLocking="true" path=""/>
                          

                           

                          I didn't make any further configuration changes to the server.xml file.

                          • 12. Re: Re: NPE in org.jboss.weld.environment.servlet.Listener
                            Martin Kouba Master

                            Hm, this file is really included in the zip file (and final WAR). But I get no NPE when I copy the WAR at webapps/ROOT.war, start the "clean" Tomcat (7.0.26), navigate to login page and post some data.

                            • 13. Re: Re: Re: NPE in org.jboss.weld.environment.servlet.Listener
                              Alexander Hartner Expert

                              When I installed the WAR file manually into the webapps folder the application worked successfully. However when I ran it in Netbeans is failed with the exception. Using Netbeans is deployed the application using a different context descriptor

                               

                              <?xml version="1.0" encoding="UTF-8"?>
                              <Context antiJARLocking="true" docBase="/home/alex/NetBeansProjects/WeldDebug/target/WeldDebug-1.0-SNAPSHOT" path=""/>
                              • 14. Re: NPE in org.jboss.weld.environment.servlet.Listener
                                Martin Kouba Master

                                Well, I added the docBase attribute manually pointing to the project's target directory and still get no error. NetBeans is probably adding some more extra configuration? I would try to use Tomcat Maven Plugin to redeploy the app instead of NetBeans GUI...

                                1 2 Previous Next