4 Replies Latest reply on Nov 10, 2010 9:05 AM by Abu Ismaaeel

    jsfunit integration with maven

    Abu Ismaaeel Newbie

      I am trying to test my war app with jsfunit in a maven build. I have followed the instructions on the wiki page about how to use maven but the war does not seem to deploy.

       

      My setup is as follows

       

      1. I have my application war which does not include any jsfunit integration tests.

       

      2. I have created a seperate mmaven project which is my JSFUnit module as explained on the wiki. I have not included anything in this module except my Integration tests. because of these tests I had to add junit as a provided scope dependency to get the project to compile.

       

       

      My pom for this module is as follows

       

         <build>
              <finalName>jsfIntegrationTest</finalName>
              <sourceDirectory>src/main/test</sourceDirectory>
              <testSourceDirectory>src/main/test</testSourceDirectory>
          </build>
          <dependencies>
              <dependency>
                  <groupId>group.id</groupId>
                  <artifactId>mywebapp</artifactId>
                  <version>1.14-SNAPSHOT</version>
                  <type>war</type>
                  <scope>runtime</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.jsfunit</groupId>
                  <artifactId>jboss-jsfunit-core</artifactId>
                  <version>1.3.0.Final</version>
                  <scope>compile</scope>
              </dependency>

               <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>3.8.1</version>
                  <scope>provided</scope>
              </dependency>  
          </dependencies>

       

       

      I then build this maven module skipping the tests and when I deploy this module onto glassfish v3 server I get the following error at deploy time:

       

      org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5159)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1933)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1605)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
          at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
          at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
          at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
          at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
          at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
          at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
          at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
          at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2659)
          at org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:1900)
          at com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:277)
          at com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:136)
          at com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:277)
          at com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:176)
          at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5151)
          ... 38 more
      Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:949)
          at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1420)
          at org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:4646)
          at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1583)
          at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2656)
          ... 45 more


      If i look at the built war I can see that Spring is included as a jar in my WEB-INF/lib directory so it should be able to find the class. Can anyone help with explaining where I have gone wrong in trying to run JSF Unit  please

       

      Regards

        • 1. Re: jsfunit integration with maven
          Stan Silvert Master

          I don't understand why you would need to mention the junit dependency.  JUnit is a dependency of Cactus which is a dependency of JSFUnit.  So you should be getting JUnit transitively.  Also, it should be a compile dependency, not provided.  JUnit should end up in your WEB-INF/lib.

           

          Looking at your stack trace, I don't see what this really has to do with JSFUnit.  Are you 100% positive that the spring jar is in your WEB-INF/lib?  ClassNotFoundException can be thrown for other reasons besides simple visibility though.  Click here to see an article on that.

           

          Stan

          • 2. Re: jsfunit integration with maven
            Abu Ismaaeel Newbie

            Thanks for your response.

             

            I had to add the junit dependecy becuase the test would not compile without it. I agree with the transitive dependency but running the build from the console would not compile. howvever it did not complain in eclipse.

             

            Looking at my setup have i interpreted the wiki page correctly in having my test classes in the jsfunit module?

             

            I am 100% positive that the spring jar is in the WEB-INF/lib folder. so this is a problem for me at the moment.

            • 3. Re: jsfunit integration with maven
              Moritz Winter Newbie

              A question about the spring-jar: is it in your maven-war generated war or in your shrinkwrap generated war or both?

               

              Secondly i did a downgrade to surefire 2.4.3 which solved alot of those problems!

              • 4. Re: jsfunit integration with maven
                Abu Ismaaeel Newbie

                The spring.jar is in my maven generated war.  What do you mean by the shrinkwrap generated war.

                And it is the maven generated war which is deployed to the server