Note that there are some explanatory texts on larger screens.

plurals
  1. POCODI with ejb stateless on Websphere liberty profile 8.5.5
    primarykey
    data
    text
    <p>I cannot launch a webapp that embedd CODI on websphere liberty profile 8.5.5 if the webapp contains a @Stateless ejb. </p> <p>I get this exception:</p> <pre><code>[ERROR ] null java.lang.reflect.InvocationTargetException [ERROR ] An error occured while initializing MyFaces: java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException [ERROR ] Uncaught.init.exception.thrown.by.servlet Faces Servlet codiTest javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @ApplicationScoped does not exist within current thread at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:342) at [internal classes] at org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig_$$_javassist_78.isAdvancedQualifierRequiredForDependencyInjection(CodiCoreConfig_$$_javassist_78.java) at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.PhaseListenerExtension.consumePhaseListeners(PhaseListenerExtension.java:110) at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleFactoryWrapper.getLifecycle(CodiLifecycleFactoryWrapper.java:67) at javax.faces.webapp.FacesServlet.init(FacesServlet.java:119) at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322) at [internal classes] [ERROR ] SRVE0266E: Error occured while initializing servlets: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:385) at [internal classes] Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @ApplicationScoped does not exist within current thread at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:342) at [internal classes] at org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig_$$_javassist_78.isAdvancedQualifierRequiredForDependencyInjection(CodiCoreConfig_$$_javassist_78.java) at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.PhaseListenerExtension.consumePhaseListeners(PhaseListenerExtension.java:110) at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleFactoryWrapper.getLifecycle(CodiLifecycleFactoryWrapper.java:67) at javax.faces.webapp.FacesServlet.init(FacesServlet.java:119) at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322) ... 1 more [WARNING ] Unknown RenderKit 'HTML_BASIC'. [WARNING ] Unknown RenderKit 'HTML_BASIC'. [ERROR ] An exception occurred java.lang.IllegalArgumentException: Could not find a RenderKit for "HTML_BASIC" </code></pre> <p>I've constated that the problem occurs only if an ejb is present in the project (in my case a @Stateless ejb).</p> <p>In this case, the application context is initialized when the server is started and the webapp installed/deployed. No problem here.</p> <p>When the first HTTP request is handled by the webapp, the <code>FacesServlet</code> is initialized and <code>CodiNavigationHandler</code> is instanciated. </p> <p>The method <code>CodiNavigationHandler.isAddViewConfigsAsNavigationCaseActivated()</code> is called in the constructor and tries to get a reference on CODI <code>JsfModuleConfig</code>. This <code>JsfModuleConfig</code> has an @ApplicationScoped annotation and the the beanManager tries to get the application context. </p> <p>This application context has already been created (when the webapp is deployed) but the <code>LibertyContextsService.initApplicationContext(String)</code>has not been called yet. So the application context is null on the <code>LibertyContextsService.applicationContexts</code> ThreadLocal variable and the error occurs:</p> <pre><code>WebBeans context with scope type annotation @ApplicationScoped does not exist within current thread </code></pre> <p>To reproduce:</p> <ul> <li>create a Dynamic Web Project</li> <li>add an almost empty beans.xml under WEB-INF (just a <code>beans</code> element)</li> <li>add an almost empty faces-config.xml under WEB-INF (just a <code>faces-config</code> element)</li> <li>add a web.xml with a faces/index.xhtml</li> <li>copy codi jars in WEB-INF/lib (<a href="http://www.apache.org/dyn/closer.cgi/myfaces/binaries/myfaces-extcdi-assembly-jsf20-1.0.5-bin.zip" rel="nofollow">http://www.apache.org/dyn/closer.cgi/myfaces/binaries/myfaces-extcdi-assembly-jsf20-1.0.5-bin.zip</a>)</li> <li><p>add a stateless bean:</p> <pre><code>import javax.annotation.PostConstruct; import javax.ejb.Stateless; @Stateless public class MyBean { @PostConstruct public void postConstruct() { System.out.println("post construct: " + this); } public String getTitle() { return "test"; } } </code></pre></li> <li><p>add a jsf bean:</p> <pre><code>import javax.inject.Inject; import javax.inject.Named; @Named public class MyController { @Inject private MyBean myBean; public String getTitle() { return myBean.getTitle(); } } </code></pre></li> <li><p>add a simple jsf web page with:</p> <pre><code>&lt;h:body&gt; &lt;h:outputText&gt;${myController.title}&lt;/h:outputText&gt; &lt;/h:body&gt; </code></pre></li> </ul> <p><strong>nota</strong>: if you remove the @stateless on the ejb, the application works.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload