Search code examples
javaprimefaceswebspheremyfacesmojarra

Primefaces + MyFaces + CDI (OpenWebBeans) + WAS 8.5


Good day,

Right now I'm trying to migrate my currently working application (Primefaces+EJB+JPA + Glassfish 4.0) to WAS 8.5. I tried using mojarra to be able to make Primefaces work. I thought I was already successful but then I stumbled upon this exception in one of the incident report in the SystemOut.log of WAS during startup:

FFDC Exception:java.lang.IllegalStateException SourceId:com.ibm.ws.webbeans.services.JCDIWebListener.contextInitialized() ProbeId:104 Reporter:com.ibm.ws.webbeans.services.JCDIWebListener@fa0f39fa java.lang.IllegalStateException: Unsupported JSF Implementation used with JCDI

And also when I tried to press a button invoking #{navigationBean.login} I get this exception:

javax.el.PropertyNotFoundException: /login.xhtml @45,111 action="#{navigationBean.login}": Target Unreachable, identifier 'navigationBean' resolved to null

Further research showed (correct me if I'm wrong) that the CDI Implementation of WAS (Apache OpenWebBeans) works best (or works only?) with MyFaces JSF Implementation. So I'm suspecting that this happened because I used Mojarra instead of MyFaces. So I went on to try to just try and replace also the OpenWebBeans only to find out that I can't change it to Weld CDI Implementation (which is what Glassfish uses).

Any suggestions on how I should address this problem? I really would like to be able to use primefaces in websphere.

Update: Update: I was able to make my first page (login page using primeface+MyFaces) appear. But when I click the first element with an EL expression (#{navigationBean.login}) pointing to an @Named class NavigationBean, I still get the

javax.el.PropertyNotFoundException: /login.xhtml @45,111 action="#{navigationBean.login}": Target Unreachable, identifier 'navigationBean' resolved to null

Further more, I also see this exception trace:

com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:221)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
   at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
   at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
   at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
   at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
   at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
   at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1385)
   at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:194)
   at com.ibm.ws.webcontainer.webapp.WebApp.sendError(WebApp.java:3263)
   at com.ibm.ws.webcontainer.webapp.WebApp.handleException(WebApp.java:3791)
   at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3772)
   at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
   at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976)
   at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
   at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
   at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88)
   at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
   at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
   at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
   at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
   at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
   at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
   at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
   at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)

With further research my assumption is: (which you can all correct in order to lead me to the right path) - Primefaces + MyFaces in Websphere works well. But if I want to implement a dependency injection I would have to resort to using @ManagedBean instead of the @Named CDI implementation (which is better by far)

But if someone knows how to make @Named still work with primefaces can you show how or at least point me to the resource you know that can help.

Many thanks.


Solution

  • I've already solved my own problem. Primefaces works well with

    MyFaces2.0+CDI(OpenWebbeans)+WAS8.5

    What I did was to include in my bin folder all the necessary dependency files of Primefaces, and some adjustment in my web.xml and then it worked fine. :)

    Here's some portion of my web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <display-name>ISIP_DCE</display-name>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
            <enabled>true</enabled>
            <async-supported>false</async-supported>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>
            *.xhtml</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
            <welcome-file>index.xhtml</welcome-file>
        </welcome-file-list>
        <context-param>
            <description> 
            </description>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
        </context-param>
        <context-param>
            <description>
            </description>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value/>
        </context-param>
        <context-param>
            <description>
            </description>
            <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
            <param-value>.xhtml</param-value>
        </context-param>
        <context-param>
            <description>
            </description>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Production</param-value>
        </context-param>
        <context-param>
            <description>
            </description>
            <param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <description>
            </description>
            <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <param-name>
                javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
            </param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <param-name>primefaces.TRANSFORM_METADATA</param-name>
            <param-value>true</param-value>
        </context-param>
        <filter>
            <filter-name>Primefaces FileUpload Filter</filter-name>
            <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
            <init-param>
                <param-name>thresholdSize</param-name>
                <param-value>51200</param-value>
            </init-param>
        </filter>
        <context-param>
            <param-name>primefaces.TRANSFORM_METADATA</param-name>
            <param-value>true</param-value>
        </context-param>
        <filter-mapping>
            <filter-name>Primefaces FileUpload Filter</filter-name>
            <servlet-name>Faces Servlet</servlet-name>
        </filter-mapping> 
        <context-param>
            <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <description>Workaround for the bug reported for JSF 2.0.
    (source: http://stackoverflow.com/questions/8026082/jsf-2-0-why-my-viewscope-beans-is-re-created-even-though-still-on-same-view)</description>
            <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
            <param-value>false</param-value>
        </context-param>
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
    </web-app>