You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by sn...@web.de on 2015/06/05 11:33:08 UTC

Included CDI-enabled Servlet Fails with ContextNotActiveException: WELD-001303

Hi,

I have a servlet that uses CDI beans. I am using weld 2.2.12.Final as 
the CDI implementation and am running on Tomcat 7.0.62 on Windows x64. 
Stand-alone, this servlet works as expected. I can access it using my 
browser and it produces the expected output.

I have a second servlet in a different web app that uses a 
RequestDispatcher to include the output from the CDI servlet. When 
included in this manner, the CDI servlet produces output up to the point 
at which it accesses an @RequestScoped bean. When the request scoped 
bean is accessed, the CDI servlet fails with the following exception:

|org.jboss.weld.context.ContextNotActiveException:  WELD-001303:  No  active contextsfor  scope type javax.enterprise.context.RequestScoped
     at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:708)
     at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:90)
...
|

I posted a detailed description of the problem at Stack Overflow, but 
haven't found a solution yet:

https://stackoverflow.com/questions/30622162/included-cdi-enabled-servlet-fails-with-contextnotactiveexception-weld-001303

It looks to me like the Weld request listener that sets up the 
application context is perhaps not being fired.

Note that I can't use a request dispatcher forward, as my application 
aggregates the output from several servlets.  Also, the application 
works correctly on IBM WebSphere Application Server (using the native 
WAS CDI support rather than Weld), but I need the application to work on 
Tomcat.

Since the app works on WebSphere, I am inclined to think that I might be 
dealing with either a Weld or a Tomcat limitation.

Could someone please I help me understand what I need to do on Tomcat to 
successfully use a RequestDispatcher to include the output of a CDI 
servlet that is external to my web app?

thanks,
Scott