NullPointerException with Tomcat
zephnodnol Jan 23, 2014 1:07 PMHi,
I'm trying to use Weld(2.1.2 FINAL) with Tomcat (7.050). I've got a fairly basic Async Servlet set up. I'm injecting a Service object into the Servlet to handle all my Redis connections. Though at the moment the injected bean is just a standard POJO to test things.
It runs fine but the Tomcat log always has this crash:
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:6151)
at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:285)
at org.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1636)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:599)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
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:722)
It looks similar to Weld-1020 on the issues board but that is marked as resolved in a previous version. So what might I be doing wrong?
beans.xml is just an empty outline.
context.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/ServiceName">
<Resource name="BeanManager"
auth="Container"
type="javax.enterprise.inject.spi.BeanManager"
factory="org.jboss.weld.resources.ManagerObjectFactory"/>
</Context>
web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
</web-app>
If it is failing to clean up objects at the end of the async handling then there will be issues with resource leaks and I'll be unable to use Weld.
Any help is much appreciated. Thanks in advance.