Topic
5 replies Latest Post - ‏2014-04-24T12:14:43Z by Michael Glauche
SystemAdmin
SystemAdmin
6420 Posts
ACCEPTED ANSWER

Pinned topic MyFaces 2.1.8/9/10 and @Inject

‏2013-02-25T17:15:34Z |
Hey there

I need one of the mentioned versions (2.1.8 / 9 or 10) of MyFaces running in a WAS 8.5.0.1. So I created a shared library, changed the apps JSF implementation to SunRI1.2 and everything seems to work just fine:

[2/25/13 18:05:27:340 CET] 000000ab WASAxis2Exten I   WSWS7037I: The /CustomerService URL pattern was configured 

for the ch.hslu.edu.enapp.enappdaemon.web.resource.webservice.Customer servlet located in the EnappDaemonWeb.war web module. [2/25/13 18:05:27:632 CET] 000000ab WebContainerL I WebContainerLifecycle startApplication OpenWebBeans Container is starting... [2/25/13 18:05:27:813 CET] 000000ab BeansDeployer I BeansDeployer validateInjectionPoints All injection points were validated successfully. [2/25/13 18:05:27:816 CET] 000000ab WebContainerL I WebContainerLifecycle startApplication OpenWebBeans Container has started, it took [183] ms. [2/25/13 18:05:27:832 CET] 000000ab DefaultFacesC I   Reading standard config META-INF/standard-faces-config.xml [2/25/13 18:05:27:956 CET] 000000ab DefaultFacesC I   Reading config /WEB-INF/faces-config.xml [2/25/13 18:05:29:114 CET] 000000ab DefaultFacesC I   Reading config : wsjar:file:/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/localhostNode01Cell/EnappDaemon.ear/EnappDaemonWeb.war/WEB-INF/lib/omnifaces-1.3.jar!/META-INF/faces-config.xml [2/25/13 18:05:29:126 CET] 000000ab LogMetaInfUti I   Artifact myfaces-api was found in version 2.1.9 from path file:/home/enapp/workspace/myfaces/myfaces-api-2.1.9.jar [2/25/13 18:05:29:127 CET] 000000ab LogMetaInfUti I   Artifact myfaces-impl was found in version 2.1.9 from path file:/home/enapp/workspace/myfaces/myfaces-impl-2.1.9.jar


The only thing not working is CDI with @Inject (it does with @EJB and also when I use the WAS internal version of MyFaces).

What am I missing?

Thanks in advance.

Greetings
Joe
Updated on 2013-02-26T10:12:38Z at 2013-02-26T10:12:38Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6420 Posts
    ACCEPTED ANSWER

    Re: MyFaces 2.1.8/9/10 and @Inject

    ‏2013-02-26T09:58:15Z  in response to SystemAdmin
    Ok, kind of "solved" it (or better found a workaround till 8.5.0.2 is released). The problem is the AnnotationProvider which needs to be added from the IBM myfaces implementation. To accomplish this a few changes are requried in the myfaces-2.1.x-impl.jar (see http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.iseries.doc/info/iseriesexp/ae/tweb_jsf_annotation.html):
    1. substitute the services directory in downloaded myfaces-2.1.x-impl.jar with the one in {WAS_HOME}\plugins\com.ibm.ws.jsf.myfaces.jar
    2. move the com.ibm.* packages into myfaces-2.1.x-impl.jar
    3. add all additional classes from {WAS_HOME}\plugins\com.ibm.ws.jsf.myfaces.jar org.apache.myfaces.shared_impl to myfaces-2.1.x-impl.jar
    4. pack the jar: jar cvfm myfaces-impl-2.1.x.jar META-INF\MANIFEST.MF *

    Add those two params to your web.xml:
    
    <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener>   <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name> <param-value>true</param-value> </context-param>
    


    Deploy the needed libraries as WAS shared library and everything works just fine. I even added omnifaces and tomahawk and my project works perfectly.

    Greetings
    Joe
    • SystemAdmin
      SystemAdmin
      6420 Posts
      ACCEPTED ANSWER

      Re: MyFaces 2.1.8/9/10 and @Inject

      ‏2013-02-26T10:12:38Z  in response to SystemAdmin
      Damn, what have I to do, to edit my post? And why does the input link thing not work? Anyways, under 1. there should be "substitute the *META-INF/*services directory"
      • fkorenschi
        fkorenschi
        3 Posts
        ACCEPTED ANSWER

        Re: MyFaces 2.1.8/9/10 and @Inject

        ‏2013-05-16T12:53:17Z  in response to SystemAdmin

        Hi there, i know i'm a bit off topic, but did you manage to use a JSF 2 implementation (2.0 or 2.1, MyFaces or JSFRI, doesn't matter so much) but more recent than the 2.0.2 that comes in WAS 8.0 with Websphere Portal 8 ?

        I've seen so many advices that seem to work with WAS alone, or with Websphere Portal 7, but things have changed a lot in respect to how the portlet bridge is packaged ... and nothing seems to work for me.

        Thanks a lot

        • swarley
          swarley
          1 Post
          ACCEPTED ANSWER

          Re: MyFaces 2.1.8/9/10 and @Inject

          ‏2013-05-16T18:43:23Z  in response to fkorenschi

          Hi

          Sorry I never used Portal 8... so can't help you there.

          Greetings

          Joe

          • Michael Glauche
            Michael Glauche
            1 Post
            ACCEPTED ANSWER

            Re: MyFaces 2.1.8/9/10 and @Inject

            ‏2014-04-24T12:14:43Z  in response to swarley

            Hi,

            i did try your setup with Websphere 8.5.5.1, but it does not seem to work anymore :(

            CDI seems working, openWebBeans is scanning the beans and is also discovering my JSF @Named beans. (ExtendedMessage: isManagedBean for class de.glauche.SomeBean returning true)

            But, EL lookups seem to be not working, i can't access the SomeBean from an xhtml page ( #{someBean} would return null)

            Any Ideas what might be causing that?

            Also, i'm always getting an FFDC with "java.lang.IllegalStateException: Unsupported JSF Implementation used with JCDI", although looking at the code it seems more like a warning, OWB does seem to continue to initialize itself...