0 Replies Latest reply on Jan 12, 2014 4:09 PM by Pascal Kesseli

    NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable with tomee-remote

    Pascal Kesseli Newbie

      Hi everyone,

       

      I am using a TomEE 1.6.0 Arquillian remote container and am trying to run a JAX-RS controller unit test. Problem is that I receive the following exception when trying to add any of my build-time enhanced entity classes to the shrinkwrap archive. The problem only occurs when using the TomEE remote container configuration in order to work with JAX-RS. The embedded container configuration works with my entities.


      java.lang.NoClassDefFoundError: org/apache/openjpa/enhance/PersistenceCapable
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at ch.diction.test.glossary.service.GlossaryControllerTest.createDeployment(GlossaryControllerTest.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:173)
        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generateDeployment(AnnotationDeploymentScenarioGenerator.java:99)
        at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.generate(AnnotationDeploymentScenarioGenerator.java:62)
        at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        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.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        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.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:84)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:65)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
        at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
        at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
        at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
        at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
        at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
        at org.junit.runners.Suite.runChild(Suite.java:127)
        at org.junit.runners.Suite.runChild(Suite.java:26)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      Caused by: java.lang.ClassNotFoundException: org.apache.openjpa.enhance.PersistenceCapable
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
         ... 76 more

       

       

      I'm using the following POM:

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>ch.diction</groupId>
        <artifactId>glossary-server</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      
      
        <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven_compiler_plugin.version>3.1</maven_compiler_plugin.version>
        <java.version>1.7</java.version>
        <surefire.version>2.16</surefire.version>
        <arquillian.version>1.1.2.Final</arquillian.version>
        <shrinkwrap.resolvers.version>2.0.1</shrinkwrap.resolvers.version>
        <war.plugin.version>2.4</war.plugin.version>
        <tomee.version>1.6.0</tomee.version>
        <tomee.classifier>jaxrs</tomee.classifier>
        <openjpa.version>2.3.0</openjpa.version>
        <commons_collections.version>4.0</commons_collections.version>
        <junit.version>4.11</junit.version>
        <mockito.version>1.9.5</mockito.version>
        <rest_assured.version>2.1.0</rest_assured.version>
        </properties>
      
      
        <build>
        <resources>
        <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
        <targetPath>ch/diction/glossary/resources</targetPath>
        <excludes>
        <exclude>**/META-INF/**</exclude>
        <exclude>**/WEB-INF/**</exclude>
        </excludes>
        </resource>
        <resource>
        <directory>src/main/resources/META-INF</directory>
        <targetPath>META-INF</targetPath>
        </resource>
        </resources>
        <testResources>
        <testResource>
        <directory>src/test/resources/container/arquillian</directory>
        <includes>
        <include>arquillian.xml</include>
        </includes>
        </testResource>
        <testResource>
        <directory>src/test/resources</directory>
        <targetPath>ch/diction/test/glossary/resources</targetPath>
        <excludes>
        <exclude>container/arquillian/arquillian.xml</exclude>
        </excludes>
        </testResource>
        </testResources>
        <plugins>
        <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven_compiler_plugin.version}</version>
        <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.openejb.maven</groupId>
        <artifactId>tomee-maven-plugin</artifactId>
        <version>${tomee.version}</version>
        <configuration>
        <tomeeVersion>${tomee.version}</tomeeVersion>
        <tomeeClassifier>${tomee.classifier}</tomeeClassifier>
        <path>${project.build.directory}/${project.artifactId}-${project.version}.war</path>
        </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>${war.plugin.version}</version>
        <configuration>
        <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
        <webResources>
        <resource>
        <directory>src/main/resources/webapp/META-INF</directory>
        <targetPath>META-INF</targetPath>
        </resource>
        </webResources>
        </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa-maven-plugin</artifactId>
        <version>${openjpa.version}</version>
        <configuration>
        <includes>**/entity/*.class</includes>
        <addDefaultConstructor>true</addDefaultConstructor>
        <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
        </configuration>
        <executions>
        <execution>
        <id>enhancer</id>
        <phase>process-classes</phase>
        <goals>
        <goal>enhance</goal>
        </goals>
        </execution>
        </executions>
        <dependencies>
        <dependency>
        <groupId>org.apache.openejb.patch</groupId>
        <artifactId>openjpa-all</artifactId>
        <version>2.3.0-nonfinal-1540826</version>
        </dependency>
        </dependencies>
        </plugin>
        </plugins>
        </build>
      
      
        <dependencyManagement>
        <dependencies>
        <dependency>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-bom</artifactId>
        <version>${shrinkwrap.resolvers.version}</version>
        <scope>import</scope>
        <type>pom</type>
        </dependency>
        <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>${arquillian.version}</version>
        <scope>import</scope>
        <type>pom</type>
        </dependency>
        </dependencies>
        </dependencyManagement>
      
      
        <profiles>
        <profile>
        <id>tomee-embedded</id>
        <activation>
        <activeByDefault>true</activeByDefault>
        </activation>
        <build>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.version}</version>
        <configuration>
        <includes>
        <include>**/AllTests.java</include>
        </includes>
        </configuration>
        </plugin>
        </plugins>
        </build>
        <dependencies>
        <dependency>
        <groupId>org.apache.openejb</groupId>
        <artifactId>arquillian-tomee-embedded</artifactId>
        <version>${tomee.version}</version>
        <scope>test</scope>
        </dependency>
        </dependencies>
        </profile>
        <profile>
        <id>tomee-remote</id>
        <build>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.version}</version>
        <configuration>
        <includes>
        <include>**/regression/**/*Test.java</include>
        </includes>
        </configuration>
        </plugin>
        </plugins>
        </build>
        <dependencies>
        <dependency>
        <groupId>org.apache.openejb</groupId>
        <artifactId>arquillian-tomee-remote</artifactId>
        <version>${tomee.version}</version>
        <scope>test</scope>
        </dependency>
        </dependencies>
        </profile>
        </profiles>
      
      
        <dependencies>
        <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>${commons_collections.version}</version>
        </dependency>
        <!-- Test dependencies -->
        <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>${rest_assured.version}</version>
        <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-depchain</artifactId>
        <scope>test</scope>
        <type>pom</type>
        </dependency>
        </dependencies>
      </project>
      

       

       

      arquillian.xml:

      <?xml version="1.0"?>
      <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian
          http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
        <container qualifier="tomee-embedded" default="true">
        <configuration>
        <property name="httpPort">-1</property>
        <property name="stopPort">-1</property>
        </configuration>
        </container>
        <container qualifier="tomee-remote">
        <configuration>
        <property name="httpPort">-1</property>
        <property name="stopPort">-1</property>
        <property name="ajpPort">-1</property>
        <property name="version">1.6.0</property>
        <property name="classifier">plus</property>
        </configuration>
        </container>
      </arquillian>
      

       

      Let me know if you need any further info and thanks for any help you can provide!