10 Replies Latest reply on Feb 2, 2011 2:42 PM by ssilvert

    CDI on Jetty 7 Embedded

    ssilvert

      I'm getting this error when I try to use CDI with Jetty 7 Embedded:

       

      INFO: BeanManager cannot be located at java:comp/BeanManager. Either you are using an archive with no beans.xml, or the Bean
      Manager has not been bound to that location in JNDI.
      

       

      I'm throwing everything into my WAR that I can think of to get this to work:

       

      @Deployment
         public static WebArchive createDeployment() {
            WebArchive war =
               ShrinkWrap.create(WebArchive.class, "test.war")
                  .setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))
                  .addPackage(Package.getPackage("org.jboss.jsfunit.example.hellojsf"))
                   /* Needed for Jetty7 embedded.  Never quite got this working.
                   * See http://community.jboss.org/wiki/HowdoIaddJARfilestothetestarchive
                   * for MavenArtifactResolver */
                  .addLibraries(MavenArtifactResolver.resolveQualifiedIds(
                     "com.sun.faces:jsf-api:2.0.4-b03",
                     "com.sun.faces:jsf-impl:2.0.4-b03",
                     "org.jboss.weld.servlet:weld-servlet:1.0.1-Final",
                     "org.glassfish.web:el-impl:2.2",
                     "javax.annotation:jsr250-api:1.0",
                     "javax.servlet:jstl:1.2",
                     "org.eclipse.jetty:jetty-plus:7.0.2.v20100331",
                     "org.mortbay.jetty:jetty-naming:6.1.12"))             
      
                  .addWebResource(EmptyAsset.INSTANCE, "beans.xml")
                  .addManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
      

       

      And, I'm putting the Weld ServletListener in my web.xml.  The Arquillian doco says I need Weld Servlet, but I assume it means this listener?

      <listener>
          <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
        </listener>
      

       

      Any idea why I'm getting the error above?

       

      Stan

        • 1. Re: CDI on Jetty 7 Embedded
          jaikiran

          What does

           

          war.toString(true);

           

          print out?

          • 2. CDI on Jetty 7 Embedded
            ssilvert

            /secured-page.xhtml

            /marathons_datatable.xhtml

            /marathons.xhtml

            /indexWithExtraComponents.xhtml

            /finalgreeting.xhtml

            /WEB-INF/

            /WEB-INF/jboss-web.xml

            /WEB-INF/lib/

            /WEB-INF/lib/el-impl-2.2.jar

            /WEB-INF/lib/jsf-impl-2.0.4-b03.jar

            /WEB-INF/lib/jsf-api-2.0.4-b03.jar

            /WEB-INF/lib/jetty-plus-7.0.2.v20100331.jar

            /WEB-INF/lib/weld-servlet-1.0.1-Final.jar

            /WEB-INF/lib/jstl-1.2.jar

            /WEB-INF/lib/jsr250-api-1.0.jar

            /WEB-INF/lib/jetty-naming-6.1.12.jar

            /WEB-INF/faces-config.xml

            /WEB-INF/beans.xml

            /WEB-INF/web.xml

            /WEB-INF/local-module-faces-config.xml

            /WEB-INF/classes/

            /WEB-INF/classes/users.properties

            /WEB-INF/classes/org/

            /WEB-INF/classes/org/jboss/

            /WEB-INF/classes/org/jboss/jsfunit/

            /WEB-INF/classes/org/jboss/jsfunit/example/

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/SetSocketTimeoutRequestStrategy.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/BasicAuthenticationTest.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/Marathon.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/CheckboxBean.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/Marathons.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/MyCDISessionBean.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/FacadeAPITest.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/MyBean.class

            /WEB-INF/classes/org/jboss/jsfunit/example/hellojsf/FormAuthenticationTest.class

            /WEB-INF/classes/META-INF/

            /WEB-INF/classes/META-INF/beans.xml

            /WEB-INF/classes/roles.properties

            /NestedNamingContainers.xhtml

            /index.xhtml

             

            Of course, that doesn't tell the whole story because there are ArchiveAppenders and an ApplicationArchiveProcessor that get called after that is printed.  Here is what ends up in WEB-INF/lib (I think):

             

            Directory of C:\Users\ssilvert\AppData\Local\Temp\Jetty_localhost_9090_export4972304374999103106test.war__test__io3446\weba

            pp\WEB-INF\lib

             

            01/25/2011  09:01 AM    <DIR>          .

            01/25/2011  09:01 AM    <DIR>          ..

            01/25/2011  09:01 AM           229,288 arquillian-core.jar

            01/25/2011  09:01 AM            22,558 arquillian-jetty-testenrichers.jar

            01/25/2011  09:01 AM         2,952,359 arquillian-jsfunit.jar

            01/25/2011  09:01 AM           241,433 arquillian-junit.jar

            01/25/2011  09:01 AM             7,295 arquillian-protocol.jar

            01/25/2011  09:01 AM           109,269 el-impl-2.2.jar

            01/25/2011  09:01 AM            28,434 jetty-naming-6.1.12.jar

            01/25/2011  09:01 AM            72,896 jetty-plus-7.0.2.v20100331.jar

            01/25/2011  09:01 AM           605,404 jsf-api-2.0.4-b03.jar

            01/25/2011  09:01 AM         1,874,563 jsf-impl-2.0.4-b03.jar

            01/25/2011  09:01 AM             5,848 jsr250-api-1.0.jar

            01/25/2011  09:01 AM           414,240 jstl-1.2.jar

            01/25/2011  09:01 AM         2,195,486 weld-servlet-1.0.1-Final.jar

                          13 File(s)      8,759,073 bytes

                           2 Dir(s)   7,111,991,296 bytes free

             

            At least I think that's correct.  It tells me "INFO: Webapp archive location: file:/C:/Users/ssilvert/AppData/Local/Temp/export4972304374999103106test.war"  But that is not there any more.  So it's really hard to tell what truly got deployed.

             

            Stan

            • 3. CDI on Jetty 7 Embedded
              dan.j.allen

              You should take a look at the test in the Arquillian Jetty 7 container adapter. It demonstrates this exact scenario. I noticed you are mixing Jetty 6 and Jetty 7 versions. I recommend switching over to Jetty 8 as it's much, much better than any previous version of Jetty.

               

              I agree, though, that some explicit instructions for this scenario are needed. Perhaps once you get it working, would you be willing to write up instructions for the documentation? I can review for you.

              • 4. Re: CDI on Jetty 7 Embedded
                ssilvert

                I got past that.  I needed to add the jetty-env.xml and the resource-env-ref as shown in the Weld doco at: http://docs.jboss.org/weld/reference/1.1.0.Final/en-US/html_single/#jetty

                 

                Also, I had to remove jetty-plus.jar and jetty-jndi.jar from the WAR.  jetty-jndi is a dependency of jetty-plus.  So, you should only list jetty-plus in the dependencies.  If you put jetty-jndi.jar in the WAR then you will get a ClassCastException because you will get the same JNDI class loaded by two classloaders.

                 

                So now that my app is finally past the initialization stage, I get the curious WELD-001303 exception below.  It looks like there was a bug fixed in Weld 1.0.1 for this, but I'm already using Weld 1.0.1:

                 

                Jan 25, 2011 2:48:59 PM org.jboss.shrinkwrap.jetty_7.api.ShrinkWrapWebAppContext <init>
                INFO: Webapp archive location: file:/C:/Users/ssilvert/AppData/Local/Temp/export887104721164780477test.war
                Jan 25, 2011 2:48:59 PM org.eclipse.jetty.util.log.Slf4jLog info
                INFO: Extract jar:file:/C:/Users/ssilvert/AppData/Local/Temp/export887104721164780477test.war!/ to C:\Users\ssilvert\AppData
                \Local\Temp\Jetty_localhost_9090_export887104721164780477test.war__test__.dkib3n\webapp
                Jan 25, 2011 2:49:00 PM org.eclipse.jetty.util.log.Slf4jLog info
                INFO: NO JSP Support for /test, did not find org.apache.jasper.servlet.JspServlet
                Jan 25, 2011 2:49:01 PM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
                INFO: WELD-000900 1.0.1 (Final)
                Jan 25, 2011 2:49:01 PM org.eclipse.jetty.util.log.Slf4jLog info
                INFO: No Transaction manager found - if your webapp requires one, please configure one.
                Jan 25, 2011 2:49:02 PM com.sun.faces.config.ConfigureListener contextInitialized
                INFO: Initializing Mojarra 2.0.4 (SNAPSHOT 20100826) for context '/test'
                Jan 25, 2011 2:49:03 PM com.sun.faces.spi.InjectionProviderFactory createInstance
                INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have s
                aid annotations processed.
                Jan 25, 2011 2:49:04 PM com.sun.faces.lifecycle.ELResolverInitPhaseListener populateFacesELResolverForJsp
                INFO: JSF1027: [null] The ELResolvers for JSF were not registered with the JSP container.
                Jan 25, 2011 2:49:04 PM org.jboss.weld.bootstrap.WeldBootstrap startContainer
                INFO: WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional ob
                servers will be invoked synchronously.
                Jan 25, 2011 2:49:04 PM org.jboss.weld.environment.servlet.Listener contextInitialized
                INFO: JSR-299 injection will not be available in Servlets, Filters etc. This facility is only available in Tomcat
                Jan 25, 2011 2:49:05 PM org.eclipse.jetty.util.log.Slf4jLog info
                INFO: WebApp@3721413 at http://localhost:9090/test
                Jan 25, 2011 2:49:06 PM org.eclipse.jetty.util.log.Slf4jLog warn
                SEVERE: /test/index.faces
                org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type @ConversationScoped
                        at org.jboss.weld.conversation.ConversationImpl.checkConversationActive(ConversationImpl.java:79)
                        at org.jboss.weld.conversation.ConversationImpl.isTransient(ConversationImpl.java:234)
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                        at java.lang.reflect.Method.invoke(Method.java:597)
                        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
                        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
                        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
                        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
                        at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
                        at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
                        at org.jboss.weld.conversation.ConversationImpl_$$_javassist_2.isTransient(ConversationImpl_$$_javassist_2.java)
                        at org.jboss.weld.conversation.AbstractConversationManager.cleanupConversation(AbstractConversationManager.java:148)
                
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                        at java.lang.reflect.Method.invoke(Method.java:597)
                        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
                        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
                        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
                        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
                        at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
                        at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
                        at org.jboss.weld.conversation.ServletConversationManager_$$_javassist_1.cleanupConversation(ServletConversationMana
                ger_$$_javassist_1.java)
                        at org.jboss.weld.jsf.WeldPhaseListener.afterRenderResponse(WeldPhaseListener.java:131)
                        at org.jboss.weld.jsf.WeldPhaseListener.afterPhase(WeldPhaseListener.java:103)
                        at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:185)
                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:103)
                        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
                        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
                        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:426)
                        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
                        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:494)
                        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
                        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)
                        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:361)
                        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
                        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
                        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
                        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
                        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
                        at org.eclipse.jetty.server.Server.handle(Server.java:337)
                        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:581)
                        at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1005)
                        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:560)
                        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:222)
                        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:417)
                        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:474)
                        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:437)
                        at java.lang.Thread.run(Thread.java:619)
                
                • 5. Re: CDI on Jetty 7 Embedded
                  aslak

                  Everything is a lot better in .next. Have you tried Weld 1.1.0.Final ? 

                  • 6. Re: CDI on Jetty 7 Embedded
                    ssilvert

                    Aslak Knutsen wrote:

                     

                    Everything is a lot better in .next. Have you tried Weld 1.1.0.Final ? 

                    With Weld 1.1.0.Final I get "Singleton is not set".

                     

                    Jan 25, 2011 3:49:35 PM com.sun.faces.config.ConfigManager initialize
                    INFO: Unsanitized stacktrace from failed start...
                    com.sun.faces.config.ConfigurationException:
                      Source Document: jar:file:/C:/Users/ssilvert/AppData/Local/Temp/Jetty_localhost_9090_export7494616314816752741test.war__te
                    st__p5xhsf/webapp/WEB-INF/lib/weld-servlet-1.1.0.Final.jar!/META-INF/faces-config.xml
                      Cause: Unable to create a new instance of 'org.jboss.weld.jsf.ConversationAwareViewHandler': java.lang.reflect.InvocationT
                    argetException
                            at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:289)
                            at com.sun.faces.config.processor.ApplicationConfigProcessor.setViewHandler(ApplicationConfigProcessor.java:523)
                            at com.sun.faces.config.processor.ApplicationConfigProcessor.processViewHandlers(ApplicationConfigProcessor.java:843
                    )
                            at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:327)
                            at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:110)
                            at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:112)
                            at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:110)
                            at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:212)
                            at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:332)
                            at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:222)
                            at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:645)
                            at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:189)
                            at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:966)
                            at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
                            at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
                            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
                            at org.jboss.arquillian.container.jetty.embedded_7.JettyEmbeddedContainer.deploy(JettyEmbeddedContainer.java:134)
                            at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)
                            at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)
                            at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                            at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                            at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:96)
                            at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:162)
                            at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
                            at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                            at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
                            at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                            at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
                            at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
                            at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
                            at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
                            at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            at java.lang.reflect.Method.invoke(Method.java:597)
                            at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
                            at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
                    Caused by: java.lang.reflect.InvocationTargetException
                            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                            at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                            at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:259)
                            ... 37 more
                    Caused by: java.lang.IllegalStateException: Singleton is not set
                            at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSi
                    ngletonProvider.java:52)
                            at org.jboss.weld.Container.instance(Container.java:58)
                            at org.jboss.weld.jsf.ConversationAwareViewHandler.<init>(ConversationAwareViewHandler.java:71)
                            ... 42 more
                    
                    • 7. Re: CDI on Jetty 7 Embedded
                      aslak

                      do you have the project source somewhere?

                      • 8. CDI on Jetty 7 Embedded
                        ssilvert

                        Yes.

                         

                        svn co https://svn.jboss.org/repos/jsfunit/trunk

                        cd jboss-jsfunit-core

                        mvn install

                        cd ../jboss-jsfunit-arquillian

                        mvn install

                        cd ../examples-arquillian

                        mvn -Pjetty-embedded test

                         

                        To change the weld version, look in examples-arquillian/pom.xml

                         

                        You can also run any of the three AS6 profiles as long as you set JBOSS_HOME.  These should run without error:

                        mvn -Pjboss6x,jbossas-managed-6 test

                        mvn -Pjboss6x,jbossas-remote-6 test

                        mvn -Pjboss6x,jbossas-embedded-6 test

                         

                        Also remember that I've moved the Arquillian integration from the Arquillian project to the jboss-jsfunit-arquillian module.

                         

                        Stan

                        • 9. Re: CDI on Jetty 7 Embedded
                          aslak

                          Ok, multiple things..

                           

                          • web.xml order of listeners matter:

                           

                            <listener>
                              <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
                            </listener>
                            <listener>
                              <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                            </listener>
                          

                           

                          The Weld listener must come before the jsf one, else the Weld JSF integration will be activated before Weld core is activated and cause "Singleton not set" exceptions.

                           

                          • Weld-Serlvet on AppClassloader as well as in deployment cause org.jboss.weld.jsf.WeldPhaseListener to be registered twice, causing "Context already activated" exception when using conversation scope. Removing it from AppClassloader resolve this.

                           

                          With those two fixes, BasicAuthenticationTest pass. FacadeAPITest has a couple of failures due to ClassNotFound exception on org.jboss.interceptors. The problem here, is that Jetty has / is setup with poor AppClassloader isolation and the TestCase, even tho deployed, will not be loaded from the WebAppClassloader, but from the AppClassloader. Weld creates Proxies based on TestClass.getClass().getClasLoader(), which results in using a Classloader where org.jboss.interceptors are not found.

                           

                          So to get FacadeAPITest to run, you have to add Weld-Servlet to AppCL and remove it from the Deployment(to avoid the listener being reigstered twice).. It's not the way it 'should' work.. but..

                           

                          Had similar issues with Tomcat embedded in the new Arquillian v as well, and I've added some ClassLoader isolation hacks so TestCase is actaully loaded in WebAppClassloader. I'll look into how this works with Jetty in the new version.

                           

                           

                          jsfunit/examples-arquillian]$ svn diff pom.xml hellojsf/pom.xml hellojsf/src/test/java/org/jboss/jsfunit/example/hellojsf/FacadeAPITest.java hellojsf/src/main/jetty/web.xml
                          Index: pom.xml
                          ===================================================================
                          --- pom.xml          (revision 552)
                          +++ pom.xml          (working copy)
                          @@ -218,7 +218,9 @@
                                     <version>7.0.2.v20100331</version>
                                     <scope>test</scope>
                                   </dependency> -->
                          +
                                 <!-- Weld servlet, EL and JSP required for testing CDI injections -->
                          +
                                   <dependency>
                                     <groupId>org.jboss.weld.servlet</groupId>
                                     <artifactId>weld-servlet</artifactId>
                          Index: hellojsf/pom.xml
                          ===================================================================
                          --- hellojsf/pom.xml          (revision 552)
                          +++ hellojsf/pom.xml          (working copy)
                          @@ -55,13 +55,8 @@
                                 <artifactId>slf4j-log4j12</artifactId>
                                 <scope>provided</scope>
                               </dependency>
                          +
                           -->
                          -    <dependency>
                          -      <groupId>org.jboss.jbossas</groupId>
                          -      <artifactId>jboss-as-client</artifactId>
                          -      <type>pom</type>
                          -      <scope>test</scope>
                          -    </dependency>
                          
                             </dependencies>
                          
                          @@ -100,7 +95,6 @@
                                         </systemProperties>
                                         <excludes>
                                           <exclude>**/FormAuthenticationTest.java</exclude>
                          -                <exclude>**/BasicAuthenticationTest.java</exclude>
                                         </excludes>
                                       </configuration>
                                     </plugin>
                          Index: hellojsf/src/test/java/org/jboss/jsfunit/example/hellojsf/FacadeAPITest.java
                          ===================================================================
                          --- hellojsf/src/test/java/org/jboss/jsfunit/example/hellojsf/FacadeAPITest.java          (revision 552)
                          +++ hellojsf/src/test/java/org/jboss/jsfunit/example/hellojsf/FacadeAPITest.java          (working copy)
                          @@ -125,9 +125,9 @@
                                  * for MavenArtifactResolver */
                                  .addWebResource(new File("src/main/jetty/jetty-env.xml"), "jetty-env.xml")
                                  .addLibraries(MavenArtifactResolver.resolveQualifiedIds(
                          -           "com.sun.faces:jsf-api:2.0.4-b03",
                          -            "com.sun.faces:jsf-impl:2.0.4-b03",
                          -            "org.jboss.weld.servlet:weld-servlet:1.1.0.Final",
                          +           "com.sun.faces:jsf-api:2.0.3-b05",
                          +            "com.sun.faces:jsf-impl:2.0.3",
                          +            //"org.jboss.weld.servlet:weld-servlet:1.1.0.Final",
                                       "org.glassfish.web:el-impl:2.2",
                                       "javax.annotation:jsr250-api:1.0",
                                       "javax.servlet:jstl:1.2")); //,
                          Index: hellojsf/src/main/jetty/web.xml
                          ===================================================================
                          --- hellojsf/src/main/jetty/web.xml          (revision 552)
                          +++ hellojsf/src/main/jetty/web.xml          (working copy)
                          @@ -13,11 +13,11 @@
                           <!--
                             Needed for Jetty 7 embedded -->
                             <listener>
                          -    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                          +    <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
                             </listener>
                          
                             <listener>
                          -    <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
                          +    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                             </listener>
                          
                          • 10. CDI on Jetty 7 Embedded
                            ssilvert

                            Thanks Aslak!  It's finally working on Jetty Embedded.  That work paid off because it runs in about half the time as JBoss AS6.  The tradeoff is the more complicated configuration. 

                             

                            I'll document this along with the JSFUnit 2.0 Beta release.  Then it's on to using it for AS7 development.  I expect JSFUnit/Arquillian to be just as fast with AS7 as it is with Jetty.  So that should give us both the easy configuration and the super speed.

                             

                            Stan