1 2 Previous Next 27 Replies Latest reply: May 5, 2012 8:29 AM by Hendy Irawan RSS

Seam Faces causes exception in JBoss AS 7 (ear deployment)

Brian Cowdery Newbie

I've been trying to put together a proof-of-concept applicaiton using .ear packaging with CDI and Seam. My persistence unit /w seam-persistence and my web-application work fine until I add Seam Faces into the mix. Once I add the seam-faces jars I get this nasty exception on startup:



17:12:08,003 WARN  [org.jboss.weld] (MSC service thread 1-3) Could not load portable extension org.jboss.seam.faces.context.FacesAnnotationsAdapterExtension: java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.6.0_25]
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [:1.6.0_25]
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [:1.6.0_25]
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [:1.6.0_25]
     at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadExtension(WeldPortableExtensionProcessor.java:117) [jboss-as-weld-7.0.2.Final.jar:7.0.2.Final]
     at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadAttachments(WeldPortableExtensionProcessor.java:100) [jboss-as-weld-7.0.2.Final.jar:7.0.2.Final]
     at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.deploy(WeldPortableExtensionProcessor.java:86) [jboss-as-weld-7.0.2.Final.jar:7.0.2.Final]
     at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)
     at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
     at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
     at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
Caused by: java.lang.NoClassDefFoundError: javax/faces/bean/RequestScoped
     at org.jboss.seam.faces.context.FacesAnnotationsAdapterExtension.<init>(FacesAnnotationsAdapterExtension.java:56) [seam-faces-impl-3.0.2.Final.jar:]
     ... 13 more
Caused by: java.lang.ClassNotFoundException: javax.faces.bean.RequestScoped from [Module "deployment.billing-ng.ear:main" from Service Module Loader]
     at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
     at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
     at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
     at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
     at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
     ... 14 more




My ear application isn't all that complex, it basically boils down to



application.ear
|
|- webapp.war
|- core-ejb.jar
|
|- lib/
|--   seam-faces.3.0.2.Final.jar
|--   seam-solder.3.0.0.Final.jar
|--   seam-persistence-api.3.0.0.Final.jar
|--   seam-persistence-impl.3.0.0.Final.jar




Is there something missing?


My war contains both a beans.xml and a faces-config.xml in WEB-INF/ so as far as I can tell AS7 should be detecting and adding in the JSF dependencies. Even if I include the sun jsf-iml.jar on my own it doesn't fix the issue.

  • 1. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    First question: Why an ear? What are you doing that requires an ear?


    Next, try using 3.1.0.Beta3 of things instead of the 3.0.0.Final version.

  • 2. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Brian Cowdery Newbie

    Still a problem in Seam 3.1.0.Beta3 :(


    I'm packaging as an ear because I have (or rather, will have) many war applications using the same EJB3 services. By packaging in an ear I can share common libraries between all of the wars instead of duplicating the libraries in each archive.


    I also intend to provide some of the applications as standalone wars so that components without a customer facing UI can be deployed to a cluster to handle dedicated tasks, while the the UI can remain on a different segment (e.g., lots of JMS traffic going to a collection servers with a partial deployment, and a session-replicated cluster handling mostly UI).


    It wouldn't be the end of the world to build everything as .war archives but it's not my first choice. And really, shouldn't Seam be working in both ear and war packages? It seems silly to limit a JEE6 CDI framework to wars only.


  • 3. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    If you're using multiple wars https://issues.jboss.org/browse/SOLDER-248 may also be a problem for you if you use the servlet bits of Solder in 3.1.0 (Servlet was moved up to Solder).


    Try putting seam-faces in the war instead of the ear. My guess is that the JSF libs are being added to the war classloader and the ear can't see them, so the Faces module isn't working correctly.

  • 4. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Brian Cowdery Newbie

    Bugger :(


    Moving the seam-faces library into the war didn't work, I actually got a nastier exception:


    20:10:11,184 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.weld.exceptions.DefinitionException: Exception List with 2 exceptions:
    Exception 0 :
    java.lang.RuntimeException: Service class org.jboss.solder.resourceLoader.ClasspathResourceLoader didn't implement the Extension interface
         at org.jboss.solder.util.service.ServiceLoader.loadClass(ServiceLoader.java:217)
         at org.jboss.solder.util.service.ServiceLoader.loadService(ServiceLoader.java:197)
         at org.jboss.solder.util.service.ServiceLoader.loadServiceFile(ServiceLoader.java:169)
         at org.jboss.solder.util.service.ServiceLoader.reload(ServiceLoader.java:143)
         at org.jboss.solder.util.service.ServiceLoader.iterator(ServiceLoader.java:284)
    



    Adding in ALL of the richfaces libraries and dependencies seems to have gotten me a little further (http://community.jboss.org/docs/DOC-16645)... But it looks like I'm bumping into SOLDER-248 as mentioned by Jason. Apparently I can't win with ear packaging :(




    20:03:48,625 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Messages] with qualifiers [@Default] at injection point [[parameter 2] of [method] org.jboss.seam.faces.status.MessagesAdapter.convert(PhaseEvent, Messages)]
         at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
         at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
         at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
         at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Messages] with qualifiers [@Default] at injection point [[parameter 2] of [method] org.jboss.seam.faces.status.MessagesAdapter.convert(PhaseEvent, Messages)]
         at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:270)
         at org.jboss.weld.bootstrap.Validator.validateObserverMethods(Validator.java:551)
         at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:341)
         at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:404)
         at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)
         at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
         ... 5 more
    



  • 5. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Brian Cowdery Newbie

    I've made some headway on this. It looks like you need to keep the seam and solder libraries in the main EAR/lib folder so that the deployer can pick them up correctly - unfortunately this means that the web-fragment.xml from seam-solder isn't initialized on the web-applications so you need to include the fragment XML in your own web.xml file.


    This article was quite helpful in figuring it out.


    And the last remaining problem is:


    10:08:52,804 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name contextInstance resolves to beans [Producer Method [RenderContext] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named @RequestScoped public org.jboss.seam.faces.context.RenderScopedContext.getContextInstance()], Producer Method [RenderContext] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named @RequestScoped public org.jboss.seam.faces.context.RenderScopedContext.getContextInstance()]]
            at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
            at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name contextInstance resolves to beans [Producer Method [RenderContext] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named @RequestScoped public org.jboss.seam.faces.context.RenderScopedContext.getContextInstance()], Producer Method [RenderContext] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named @RequestScoped public org.jboss.seam.faces.context.RenderScopedContext.getContextInstance()]]
            at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:456)
            at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:342)
            at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:404)
            at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)
            at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
            ... 5 more
    





    I think I might need to step back and put together an extremely basic .ear for testing. It doesn't seem like there's any good way to get an EAR archive deployed to AS7 when using Seam.


  • 6. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    Looks like you may have two versions or instances of Seam Faces that it's picking up.

  • 7. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Brian Cowdery Newbie

    Nope, only one copy of Seam Faces in the whole project.



    Still stuck with this exception




    22:22:04,632 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."billing-ng.ear".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name caughtException resolves to beans [Producer Method [ExceptionToCatch] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @ConversationScoped @Named public org.jboss.solder.exception.control.ExceptionHandlerDispatch.getExceptionToCatch()], Producer Method [ExceptionToCatch] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @ConversationScoped @Named public org.jboss.solder.exception.control.ExceptionHandlerDispatch.getExceptionToCatch()]]
         at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
         at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
         at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
         at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name caughtException resolves to beans [Producer Method [ExceptionToCatch] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @ConversationScoped @Named public org.jboss.solder.exception.control.ExceptionHandlerDispatch.getExceptionToCatch()], Producer Method [ExceptionToCatch] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @ConversationScoped @Named public org.jboss.solder.exception.control.ExceptionHandlerDispatch.getExceptionToCatch()]]
         at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:456)
         at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:342)
         at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:404)
         at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)
         at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
         ... 5 more
    
    




    Although I am finding bugs (SEAMFACES-206) in JIRA that could be the cause of this... I think I'm going to have to drop this project for now and try again with the next release of Jboss and Seam. Thanks for the help everybody!


  • 8. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    It's a bug (not sure about SEAMFACES-206, I'll have to dig into that one) but I'll have this one fixed for you shortly. https://issues.jboss.org/browse/SOLDER-294

  • 9. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    Wait, it's not a bug, there's got to be multiple versions of Solder on the classpath.

  • 10. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Brian Cowdery Newbie

    Success! Thanks Jason, that was the problem :)


    In my case it was because my dependency manager (Ivy) was bringing in the transient Solder dependency for Seam Persistence and on Seam Faces. I'm using a different Ivy config for each component so there was no way for it to know that Solder had already been added to the EAR/lib as well as the WAR.


    In any case, the application deploys to JBoss AS 7.0.2.Final with Seam 3.1.0.Beta3 and I'm able to hit my JSF Hello World page without any issues.


    I've also found that it's not necessary for me to include the Solder web-fragment.xml in my own web.xml anymore.


    For anyone who's interested, the EAR application structure looks like this:


    billing-ng.ear
    |
    |- lib/
    |--    seam-persistence-3.1.0.Beta3.jar
    |--    seam-persistence-api-3.1.0.Beta3.jar
    |--    seam-transaction-api-3.1.0.Beta3.jar
    |--    solder-api-3.1.0.Beta3.jar
    |--    solder-impl-3.1.0.Beta3.jar
    |--    solder-logging-3.1.0.Beta3.jar
    |
    |- billing-ng-core.jar (EJB's and Hibernate entities)
    |- META-INF/
    |--    beans.xml
    |--    ejb-jar.xml
    |--    persistence.xml
    |
    |- billing-ng-web.war 
    |- WEB-INF/
    |--    beans.xml
    |--    faces-config.xml
    |--    pretty-config.xml
    |--    web.xml
    |- WEB-INF/lib/
    |---        prettyfaces-jsf2-3.3.0.jar
    |---        seam-faces-3.1.0.Beta3.jar
    |---        seam-faces-api-3.1.0.Beta3.jar
    |---        seam-international-3.1.0.Beta3.jar
    |---        seam-international-api-3.1.0.Beta3.jar
    

  • 11. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    Good to know Brian. Would you mind keeping us informed with how your example / trial ends up going? Using Ant + Ivy would be a great blog post and something we'd happily link to for others looking about how to set it up correctly.


    I would, however, recommend using the same Ivy config if possible, otherwise you will certainly run into more of these sorts of issues.

  • 12. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Brian Cowdery Newbie

    Sure, I'll write something up later when I've worked out the kinks. This is a side project of mine that gets worked on between work, sleep, and entertaining 2 kids so who knows when I'll find the time - but I will write something eventually :P


    Thanks again for the help!


  • 13. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Franck Garcia Newbie

    Thanks for the layout of your ear, it's helpful. I'm using Maven to build up my ear. My war is referencing my ejb modules which themselves have dependencies on other SEAM 3 module (eg. persistence etc). Even if I specify the scope provided when referencing my ejb module in my war, Maven pulls the seam module referred by the ejb and they end up inside my WEB-INF/lib making my ear undeployable! the problem is that I reference the seam 3 bom file which specify the scope of the SEAM 3 modules. Specifying the scope in the dep management section has the surprising effect of overriding the provided scope I explicitly set on my ejb module. Thanks Maven! I don't know if it makes sense but avoiding specifying the scope of the SEAM 3 module in the BOM will make our life easier.

  • 14. Re: Seam Faces causes exception in JBoss AS 7 (ear deployment)
    Jason Porter Master

    Can't please everyone with maven :( Our reasoning behind specifying the scope in the BOM is to make (what we believe is the larger use case) the easiest by only requiring people to specify the non api artifact and then the api artifact will be brought in at the correct compile scope. It would be possible to create an ear bom. Something to think about. Also, you're more than welcome to create one and issue a pull request :)

1 2 Previous Next