2
votes

Problem: Using REST service and SIP Servlets in one project is leading to an exception, if injection via EJB is also used.

What steps will reproduce the problem?

  1. Adding a Sip Servlet and REST service in the project (REST service is activated via a class extending Application and annotated with @ApplicationPath, which is the Java EE 6 "no XML" approach, activating JAX-RS)

  2. Using the REST service and/or SIP servlet will not produce any errors.

  3. Add an injected service via @EJB to the project.

  4. Using the REST service results in following exception:

Error:

Exception sending request destroyed lifecycle event to listener instance of class org.jboss.weld.servlet.WeldListener: java.lang.NullPointerException
    at org.jboss.weld.context.AbstractBoundContext.deactivate(AbstractBoundContext.java:71) [weld-core-1.1.8.Final.jar:2012-04-29 10:45]
    at org.jboss.weld.context.http.HttpRequestContextImpl.deactivate(HttpRequestContextImpl.java:86) [weld-core-1.1.8.Final.jar:2012-04-29 10:45]
    at org.jboss.weld.servlet.WeldListener.requestDestroyed(WeldListener.java:103) [weld-core-1.1.8.Final.jar:2012-04-29 10:45]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) [jbossweb-7.0.16.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.16.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.16.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.16.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.16.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.16.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.16.Final.jar:]
    at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_37]

I am using:

  • Mobicents: mss-2.0.0.FINAL-jboss-as-7.1.2.Final
  • OS: Mac OS X 10.6.8, Ubuntu 12.04, Windows 8

I've also posted the problem to Google Code, where a test project has been uploaded and can be used to run the actual test case. There is a test file in src/test/java which is calling the deployed REST service. In the original project this should result in the error above.

If the SIP Servlet is not activated (e.g. by renaming sip.xml) no error occurs on calling the REST service.

If the SIP Servlet is activated and the injected service HelloWorldService is removed there is also no error calling the REST service.

2

2 Answers

1
votes

There are 2 solutions. You wait until the weld-core-1.1.8.FINAL.jar will be updated! Or you get the source code and do a hard fix in org.jboss.weld.context.AbstractBoundContext:

public void deactivate() {
if (getBeanStore() != null )
{ getBeanStore().detach(); super.deactivate(); }
}

For more information see https://issues.jboss.org/browse/WELD-1020?_sscc=t

0
votes

I am running mss-3.0.0-SNAPSHOT-jboss-as-7.1.3.Final, and worked-around this issue by injecting the EJB with @EJB rather than @Inject (and removing the beans.xml file).

My application is deployed as an EAR assembled from multiple modules: EJBs, SIP servlets, and the web servlets and JAX-RS/RESTEasy application and resources (packaged together).