10 Replies Latest reply on Feb 8, 2013 8:42 AM by kaefert

    Errai + CDI in an EAR bundled application, anybody done it?

    tnfink

      Happily I discovered the 1.1-Final release of Errai, downloaded it, tested the CDI integration with JBoss AS 6.0.0.CR1, and was even more happy that it worked. :-)

       

      Being old fashioned, I would prefer an EAR-based packaging instead of the lighweight WAR packaging. Thus I started to set up a test project in my spare time based on the Errai-CDI-Maven archetype.

       

      I put the errai-cdi-1.1-Beta2.jar into the lib directory of my WAR-file inside the EAR, and get this error at deployment:

       

       

       

      09:28:40,422 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/evento]] Servlet /evento threw load() exception: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null

       

       

      09:28:40,411 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/evento]] StandardWrapper.Throwable: java.lang.RuntimeException: Failed to create service

      at org.jboss.errai.bus.server.servlet.AbstractErraiServlet.init(AbstractErraiServlet.java:98) [:1.1-Final]

      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1208) [:6.0.0.20101110-CR1]

      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1108) [:6.0.0.20101110-CR1]

      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3628) [:6.0.0.20101110-CR1]

      ...
      ...
      Caused by: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null
      at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:693) [:6.0.0.20101110-CR1]
      at org.jboss.errai.cdi.server.CDIServiceLocator.locateService(CDIServiceLocator.java:20) [:]
      at org.jboss.errai.bus.server.servlet.AbstractErraiServlet.init(AbstractErraiServlet.java:96) [:1.1-Final]

       

       

       

      It seems that the Errai-Service is not found by Weld.

       

      Does anyone have a working example?

      (Then, I could avoid to analyze the problem in detail...)

        • 1. Re: Errai + CDI in an EAR bundled application, anybody done it?
          heiko.braun

          Your assumption is correct. The servlet entry point fails to locate the errai service (CDI bean in this case). It's most probably a classloading problem. Let me try to reproduce it.

          • 2. Re: Errai + CDI in an EAR bundled application, anybody done it?
            heiko.braun

            It's a problem with the extension discovery: https://jira.jboss.org/browse/JBAS-8683

            It seems that the CDI Extension is not being discovered when shipped as a web application inside an EAR.

            I's similar to the problem Errai used to have in previous versions, but now resides with the CDI-AS integration.

            For the time being, I cannot think of a workaround, except not using ear deployments.

            • 3. Re: Errai + CDI in an EAR bundled application, anybody done it?
              heiko.braun

              Regarding the stack trace: The CDI extension is not being discovered and executed, hence the Errai Servlet entry point fails to locate the Service, which is created when the CDI extension (as of portable extension, see spec) is being executed.

              1 of 1 people found this helpful
              • 4. Re: Errai + CDI in an EAR bundled application, anybody done it?
                tnfink

                Thanks for the quick replies.

                 

                I

                • moved the CDI extension and the errai-bus library from the war to the lib directory of the ear
                • created a new configuration jar containing the ErrayService.properties and also put it into the EAR lib directory (BTW I had to move the properties file to a org/jboss/errai/bus subdirectory. Otherwise Errai did not find it.)

                 

                The CDI extension is now starting up. But it crashes when it tries to register a MessageCallback for a service of mine:

                 

                21:36:09,693 INFO  [org.jboss.errai.bus.server.service.bootstrap.BootstrapContext] Running deferred bootstrap tasks ...

                21:36:09,702 INFO  [org.jboss.errai.bus.server.service.bootstrap.OrderedBootstrap] Bootstrap complete. Ready to rumble!

                21:36:09,726 INFO  [org.jboss.errai.cdi.server.CDIExtensionPoints] Register MessageCallback: public@Service @ApplicationScoped class de.evento.server.UserServiceImpl

                21:36:09,726 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=vfs:///Applications/Entwicklung/JBoss/jboss/jboss-6.0.0.20101110-CR1/server/default/deploy/evento-ear-0.1-SNAPSHOT.ear_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:

                Exception 0 :

                org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null

                at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:693)

                at org.jboss.errai.cdi.server.Util.lookupCallbackBean(Util.java:45)

                at org.jboss.errai.cdi.server.CDIExtensionPoints.subscribeServices(CDIExtensionPoints.java:198)

                at org.jboss.errai.cdi.server.CDIExtensionPoints.afterBeanDiscovery(CDIExtensionPoints.java:172)

                at org.jboss.errai.cdi.server.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$Applications$Entwicklung$JBoss$jboss$jboss-6$0$0$20101110-CR1$server$default$deploy$eventkoordination-ear-0$1-SNAPSHOT$ear"-Built-in-Extension-org$jboss$errai$cdi$server$CDIExtensionPoints_$$_WeldClientProxy.afterBeanDiscovery(org$jboss$weld$bean-jboss$classloader:id="vfs:$$$Applications$Entwicklung$JBoss$jboss$jboss-6$0$0$20101110-CR1$server$default$deploy$eventkoordination-ear-0$1-SNAPSHOT$ear"-Built-in-Extension-org$jboss$errai$cdi$server$CDIExtensionPoints_$$_WeldClientProxy.java)

                Thus, it seems that Weld forwards my CDI-Bean (UserServiceImpl) to the Errai-CDI-extension. But, when the Erray-CDI-extension tries to access/create my bean, Weld has problems.

                 

                I will look at it again, when I find some more spare time :-)

                21:36:09,693 INFO  [org.jboss.errai.bus.server.service.bootstrap.BootstrapContext] Running deferred bootstrap tasks ...
                21:36:09,702 INFO  [org.jboss.errai.bus.server.service.bootstrap.OrderedBootstrap] Bootstrap complete. Ready to rumble!
                21:36:09,726 INFO  [org.jboss.errai.cdi.server.CDIExtensionPoints] Register MessageCallback: public@Service @ApplicationScoped class de.everythingmobile.eventkoordination.server.UserServiceImpl
                21:36:09,726 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=vfs:///Applications/Entwicklung/JBoss/jboss/jboss-6.0.0.20101110-CR1/server/default/deploy/eventkoordination-ear-0.1-SNAPSHOT.ear_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
                Exception 0 :
                org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null
                at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:693)
                at org.jboss.errai.cdi.server.Util.lookupCallbackBean(Util.java:45)
                at org.jboss.errai.cdi.server.CDIExtensionPoints.subscribeServices(CDIExtensionPoints.java:198)
                at org.jboss.errai.cdi.server.CDIExtensionPoints.afterBeanDiscovery(CDIExtensionPoints.java:172)

                at org.jboss.errai.cdi.server.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$Applications$Entwicklung$JBoss$jboss$jboss-6$0$0$20101110-CR1$server$default$deploy$eventkoordination-ear-0$1-SNAPSHOT$ear"-Built-in-Extension-org$jboss$errai$cdi$server$CDIExtensionPoints_$$_WeldClientProxy.afterBeanDiscovery(org$jboss$weld$bean-jboss$classloader:id="vfs:$$$Applications$Entwicklung$JBoss$jboss$jboss-6$0$0$20101110-CR1$server$default$deploy$eventkoordination-ear-0$1-SNAPSHOT$ear"-Built-in-Extension-org$jboss$errai$cdi$server$CDIExtensionPoints_$$_WeldClientProxy.java)

                 

                • 5. Re: Errai + CDI in an EAR bundled application, anybody done it?
                  heiko.braun
                  1 of 1 people found this helpful
                  • 6. Re: Errai + CDI in an EAR bundled application, anybody done it?
                    tnfink

                    Thanks for the link.

                    For me it seems that there are still some tasks open to use CDI inside an EAR.

                     

                    I looked at my problem a little bit more closely. The Erray-extension is detected and it detects the @Service tagged CDI components inside the WAR. But, then it can not access them.

                     

                    I stopped now my EAR-test and try to use a WAR with separated EJB and JPA modules. This would still give me modularity on the build level.

                    • 7. Re: Errai + CDI in an EAR bundled application, anybody done it?
                      heiko.braun
                      I looked at my problem a little bit more closely. The Erray-extension is detected and it detects the @Service tagged CDI components inside the WAR. But, then it can not access them.

                      you mean, when you move around  the libraries, right? but not with the default setup (WEB-INF/lib inside EAR). Or am I wrong?

                      • 8. Re: Errai + CDI in an EAR bundled application, anybody done it?
                        heiko.braun

                        As you can see from the discussions, this has been a dark spot in the CDI spec, which should have been clarified in more recent versions of the specifications. The Weld team is currently looking into this. Until then I suggest you stick to the war deployment, as you already said.

                        • 9. Re: Errai + CDI in an EAR bundled application, anybody done it?
                          tnfink

                          yes, I had to move all the libraries quite a lot, to get it to work, or at least to nearly work.

                          • 10. Re: Errai + CDI in an EAR bundled application, anybody done it?
                            kaefert

                            Hi there!

                             

                            I am looking for the same thing as what you posted in your original question (an errai project packaged with other things like an ejb project into an ear package)

                             

                            My original problem is that I wanted to separate my entities from my gwt project, without having to list them in the persistence.xml file.

                            But I found that this doesn't seem to work (see the answer to http://stackoverflow.com/questions/4433341/what-is-the-right-path-to-refer-a-jar-file-in-jpa-persistence-xml-in-a-web-app)

                             

                            Now I wanted to dive into the whole jboss application server universe to solve this problem for myself. I found that there is a beautiful java ee + ear sample that has a multi project setup with seperated ear, ejb and web projects, and I found that there are really nice errai samples, but which are all single-project setups. I've not managed to mix those together to a working multi project setup with a gwt app that uses the beans of the ejb project yet, although I'm already trying for a few weeks..

                             

                            I've found these quite old blog posts that describe the process, but I didn't mange to get those run with current versions of the involved projects either.

                            http://www.javacodegeeks.com/2010/09/gwt-ejb3-maven-jboss-51-integration.html

                            http://jamies-gwt.blogspot.co.at/2010/03/walkthrough-integrating-gwt-with-jboss.html

                            http://code.google.com/p/gwt-ejb-sample/

                             

                            It would be great if anyone else who has tried this or thought about it could tell me about it.