1 Reply Latest reply on Jan 19, 2012 1:18 PM by Anton Lisovenko

    Test runs in Eclipse, but fails in Maven

    Anton Lisovenko Newbie

      Hi.

       

      I have several complicated CDI-EJB tests, which run successfully in Eclipse IDE, but fail when I run them using mvn integration-test with the following exception:

       


       

      ......


      19.01.2012 20:40:54 com.sun.ejb.containers.BaseContainer initializeHome

      INFO: EJB5181:Portable JNDI names for EJB K4PaymentTypeDAO: [java:global/KaskoCalculator/K4PaymentTypeDAO, java:global/KaskoCalculator/K4PaymentTypeDAO!com.rstk.kasko.dao.K4

      tTypeDAO]

      19.01.2012 20:40:54 com.sun.ejb.containers.BaseContainer initializeHome

      INFO: EJB5181:Portable JNDI names for EJB KaskoCalculator: [java:global/KaskoCalculator/KaskoCalculator!com.rstk.kasko.ejb.KaskoCalculator, java:global/KaskoCalculator/Kasko

      ator]

      19.01.2012 20:40:54 com.sun.ejb.containers.BaseContainer initializeHome

      INFO: EJB5181:Portable JNDI names for EJB ProlongationDAO: [java:global/KaskoCalculator/ProlongationDAO, java:global/KaskoCalculator/ProlongationDAO!com.rstk.kasko.dao.Prolo

      nDAO]

      19.01.2012 20:40:55 org.jboss.weld.bootstrap.WeldBootstrap <clinit>

      INFO: WELD-000900 1.1.0 (Final)

      19.01.2012 20:40:58 org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA

      INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.

      19.01.2012 20:40:58 org.glassfish.api.ActionReport failure

      SEVERE: Exception while loading the app

      classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)

      SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@1df06863

      19.01.2012 20:40:58 org.hibernate.impl.SessionFactoryImpl close

      INFO: closing

      19.01.2012 20:40:59 org.glassfish.deployment.admin.DeployCommand execute

      SEVERE: Exception while loading the app : WELD-000117 Required service org.jboss.weld.servlet.api.ServletServices has not been specified

      org.jboss.weld.exceptions.IllegalStateException: WELD-000117 Required service org.jboss.weld.servlet.api.ServletServices has not been specified

              at org.jboss.weld.bootstrap.WeldBootstrap.verifyServices(WeldBootstrap.java:506)

              at org.jboss.weld.bootstrap.WeldBootstrap.startContainer(WeldBootstrap.java:245)

              at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:167)

              at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)

              at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:270)

              at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)

              at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)

              at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:388)

              at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:360)

              at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)

              at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1069)

              at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)

              at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1249)

              at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1237)

              at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.executeCommand(CommandExecutorImpl.java:147)

              at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:99)

              at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:89)

              at org.jboss.arquillian.container.glassfish.embedded_3_1.GlassFishContainer.deploy(GlassFishContainer.java:196)

              at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:157)

              at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:124)

              at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:267)

              at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:123)

              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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

              at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

              at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

              at org.jboss.arquillian.container.impl.client.container.DeploymentExceptionHandler.verifyExpectedExceptionDuringDeploy(DeploymentExceptionHandler.java:50)

              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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

              at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

              at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createDeploymentContext(ContainerDeploymentContextHandler.java:78)

              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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

              at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

              at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

       

      So, my ejb container is initialized, ejb container is started but WELD is failing.

       

      I use Glassfish-embedded server.

       

      Here is my Test:

       


      @RunWith(Arquillian.class)
      public class BaseCDITestIT {
          public static final String WEBAPP_SRC = "src/main/webapp";
      
      @Deployment
          public static WebArchive createArchiveAndDeploy() {
              MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom(
                  "pom.xml");
              return ShrinkWrap
                  .create(WebArchive.class, "KaskoCalculator.war")
                  .addPackages(true, "com/rstk/kasko")
                  // .addAsManifestResource("arquillian/test-persistence.xml", "persistence.xml")
                  .addAsResource("arquillian/test-persistence.xml", "META-INF/persistence.xml")
                  .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/beans.xml"))
                  .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/spring/applicationContext.xml"),
                      "spring/applicationContext.xml")
                  .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/spring/applicationContext-security.xml"),
                      "spring/applicationContext-security.xml")
                  .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/spring/applicationContext-roles.xml"),
                      "spring/applicationContext-roles.xml").setWebXML("arquillian/web.xml")
                  .addAsLibraries(resolver.artifact("org.jboss.seam.faces:seam-faces:3.0.0.Final").resolveAsFiles());
          }
      


       

      and pom configuration (tried both failsave and surefire plugin but both with the same result), some dependencies are skipped.:

       

      {code:xml}

      <dependency>
                                    <groupId>org.glassfish.extras</groupId>
                                    <artifactId>glassfish-embedded-all</artifactId>
                                    <version>3.2-b06</version>
                                    <scope>provided</scope>
                          </dependency>
      
      
      <dependency>
                                    <groupId>org.jboss.arquillian.junit</groupId>
                                    <artifactId>arquillian-junit-container</artifactId>
                                    <!-- <version>1.0.0.CR6</version> -->
                                    <scope>test</scope>
                          </dependency>
                          <dependency>
                                    <groupId>org.jboss.arquillian.protocol</groupId>
                                    <artifactId>arquillian-protocol-servlet</artifactId>
                                    <version>1.0.0.CR6</version>
                                    <scope>test</scope>
                          </dependency>
                          <dependency>
                                    <groupId>org.jboss.arquillian.container</groupId>
                                    <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
                                    <version>1.0.0.CR2</version>
                                    <scope>test</scope>
                          </dependency>
                          <dependency>
                                    <groupId>org.jboss.shrinkwrap.resolver</groupId>
                                    <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
                                    <scope>test</scope>
                          </dependency>
      
      
      
      
      
      
      
      
      
      <plugin>
      
                  <artifactId>maven-surefire-plugin</artifactId>
                  <executions>
                    <execution>
                      <id>surefire-it</id>
                      <phase>integration-test</phase>
                      <goals>
                        <goal>test</goal>
                      </goals>
                      <configuration>
                        <skip>false</skip>
                        <printSummary>true</printSummary>
                        <forkMode>always</forkMode>
                        <includes>
                          <include>**/*IT.java</include>
                        </includes>
                      </configuration>
                    </execution>
                  </executions>
                </plugin>
      


       

      Just to repeat myself: everything runs ok in IDE, but fails in maven! Seems some paths are not resolved, though when I tried to set WEBAPP_SRC  constant to some other value - test failed with FileNotFoundException.

       

      Thank in advance!!

       

      Message was edited by: Anton Lisovenko (I'm very sorry for markup, the wiki is just terrible, I could not cope with it....)