Arquillian Shrinkwrap ClassCastException PersistenceProviderImpl
assimilate Dec 21, 2017 9:18 AMI have been looking at this problem for almost a week now, and I've run out of options. I am guessing there is some conflict between the classes that I am including.
I started with the sample arquillian test and extended it to test some of my ejbs. Hit various obstacles with missing classes, dependencies etc, which I think I resolved for the most part, but right now, I am stuck at this error:
"Caused by: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"mytest.war\".FIRST_MODULE_USE" => "WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"mytest.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0019: Could not deploy application packaged persistence provider 'org.apache.openjpa.persistence.PersistenceProviderImpl'
Caused by: java.lang.ClassCastException: class org.apache.openjpa.persistence.PersistenceProviderImpl"}}"
I am using the latest arquillian, with WildFly 11.0, Maven. The app stack is Java, OpenJPA, with a bunch of third party jars.
Arquillian/Shrinkwrap is new to me, and I've been sort of feeling my way as I go forward. Please lmk if you have any suggestions! TIA!
Code snippets below, some are rather long... sorry!
Code:
@Deployment public static WebArchive createTestArchive() { File[] files = Maven.resolver().loadPomFromFile("C:\\devnewworkspace\\project1\\pom.xml") .importDependencies(ScopeType.TEST, ScopeType.PROVIDED, ScopeType.RUNTIME, ScopeType.COMPILE, ScopeType.IMPORT) .importRuntimeAndTestDependencies() .resolve().withTransitivity().asFile(); WebArchive war = ShrinkWrap.create(WebArchive.class, "mytest.war"); war.addPackages(true, "com.company.iec"); war.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class) .importDirectory("src/main/java").as(GenericArchive.class), "/", Filters.includeAll()); war.addAsLibraries(files); war.addAsResource(EmptyAsset.INSTANCE, "beans.xml"); war.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml"); war.addAsWebInfResource(new File( "src/main/webapp/WEB-INF/jboss-deployment-structure.xml")); System.out.println(war.toString(true)); return war; }
Arquillian.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <!-- Configuration to be used when the WidlFly remote profile is active --> <container qualifier="wildfly-remote" default="true"> <configuration> <property name="managementAddress">127.0.0.1</property> <property name="managementPort">9990</property> <property name="username">admin</property> <property name="password">admin</property> </configuration> </container> </arquillian>
pom.xml
<properties> <!-- Explicitly declaring the source encoding eliminates the following message: --> <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <version.junit>4.12</version.junit> <!-- JBoss dependency versions --> <version.jboss.maven.plugin>7.5.Final</version.jboss.maven.plugin> <!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. --> <version.jboss.bom.eap>6.4.0.GA</version.jboss.bom.eap> <!-- <version.openjpa>2.4.0-nonfinal-1598334</version.openjpa> --> <version.openjpa>2.4.2</version.openjpa> <!-- other plugin versions --> <version.surefire.plugin>2.1</version.surefire.plugin> <version.war.plugin>2.1.1</version.war.plugin> <!-- maven-compiler-plugin --> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> <version.arquillian_persistence>1.1.15.Final</version.arquillian_persistence> <version.arquillian_core>1.1.15.Final</version.arquillian_core> <version.surefire.plugin>2.20.1</version.surefire.plugin> <version.org.wildfly>8.2.1.Final</version.org.wildfly> <version.shrinkwrap.resolvers>3.0.1</version.shrinkwrap.resolvers> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-6.0</artifactId> <version>3.0.2.Final</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>1.1.15.Final</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.4.1208-jdbc42-atlassian-hosted</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- First declare the APIs we depend on and need for compilation. All of them are provided by JBoss EAP 6 --> <!-- Import the JAX-RS API, we use provided scope as the API is included in JBoss EAP 6 --> <!--<dependency> <groupId>org.jboss.spec.javax.ws.rs</groupId> <artifactId>jboss-jaxrs-api_1.1_spec</artifactId> <scope>provided</scope> </dependency> --> <!-- Import the EJB API, we use provided scope as the API is included in JBoss EAP 6 --> <dependency> <groupId>org.jboss.spec.javax.ejb</groupId> <artifactId>jboss-ejb-api_3.1_spec</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.ejb3</groupId> <artifactId>jboss-ejb3-ext-api</artifactId> <version>2.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.jms</groupId> <artifactId>jms</artifactId> <version>1.1</version> <scope>provided</scope> </dependency> <!-- Now we declare any tools needed --> <!-- Updated HTTP Client for Azure Bus from 4.0.1 to 4.3.4 --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.3.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${version.junit}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>1.6.2</version> <scope>provided</scope> </dependency> <!-- <dependency> <groupId>com.ibm.db2.jcc</groupId> <artifactId>db2jcc_license_cu</artifactId> <version>3.8.47</version> <scope>provided</scope> </dependency> --> <dependency> <groupId>com.hazelcast</groupId> <artifactId>hazelcast</artifactId> <version>3.8.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa</artifactId> <version>${version.openjpa}</version> <scope>provided</scope> </dependency> <!-- <dependency> <groupId>org.apache.openejb.patch</groupId> <artifactId>openjpa</artifactId> <version>${version.openjpa}</version> </dependency> --> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.8.3</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hectorclient</groupId> <artifactId>hector-core</artifactId> <version>1.1-4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz-jobs</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>com.bikeemotion</groupId> <artifactId>quartz-hazelcast-jobstore</artifactId> <version>1.0.4</version> </dependency> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.6.3</version> </dependency> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.3</version> <classifier>jdk15</classifier> <scope>provided</scope> </dependency> <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId> <version>1.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.15</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>javax.mail-api</artifactId> <version>1.4.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.opensaml</groupId> <artifactId>opensaml</artifactId> <version>2.5.3</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.opensaml</groupId> <artifactId>xmltooling</artifactId> <version>1.3.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.google.code.geocoder-java</groupId> <artifactId>geocoder-java</artifactId> <version>0.15</version> <scope>provided</scope> </dependency> <dependency> <groupId>net.sf.opencsv</groupId> <artifactId>opencsv</artifactId> <version>2.3</version> <scope>provided</scope> </dependency> <!-- Added for Azure Service Bus --> <dependency> <groupId>com.microsoft.azure</groupId> <artifactId>azure-servicebus</artifactId> <version>0.9.7</version> </dependency> <dependency> <groupId>ma.glasnost.orika</groupId> <artifactId>orika-core</artifactId> <version>1.4.2</version> </dependency> <!-- Jersey jars Start --> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.19</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId> <version>1.19</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.19</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>1.19</version> </dependency> <!-- <dependency> <groupId>com.consert.logger</groupId> <artifactId>logging-logback</artifactId> <version>1.0.0</version> <scope>provided</scope> </dependency> --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.10.19</version> <scope>test</scope> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.11</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.shrinkwrap.resolver</groupId> <artifactId>shrinkwrap-resolver-depchain</artifactId> <version>${version.shrinkwrap.resolvers}</version> <scope>test</scope> <type>pom</type> </dependency> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <!-- Maven will append the version to the finalName (which is the name given to the generated war, and hence the context root) --> <finalName>${project.artifactId}</finalName> <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <versionRange>[1.8,)</versionRange> <goals> <goal>run</goal> </goals> </pluginExecutionFilter> <action> <execute> <runOnIncremental>false</runOnIncremental> </execute> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> <driver>org.postgresql.Driver</driver> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> <dependencies> <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.4.1208-jdbc42-atlassian-hosted</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8</version> <configuration> <additionalProjectFacets> <jpt.jpa>2.3</jpt.jpa> </additionalProjectFacets> </configuration> </plugin> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>2.7.1</version> <dependencies> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <!-- The red X in JBDS does not seem to prevent anything from working. There does not seem to be a red X for JRE 6 w/ 2.8.1. I think JRE 7 & 8 use a modified version of 2.7.1 java com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck --> <version>2.7.1</version> </dependency> </dependencies> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <defaultOptions> <bindingFiles> <bindingFile>${basedir}/src/main/resources/binding.xml</bindingFile> </bindingFiles> <noAddressBinding>true</noAddressBinding> </defaultOptions> <!-- Maven auto-compiles any source files under target/generated-sources/ --> <sourceRoot>${basedir}/target/generated-sources/jaxws</sourceRoot> <wsdlOptions> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>remove-meta</id> <phase>generate-sources</phase> <configuration> <target> <delete dir="target\generated-sources\metamodel" includeemptydirs="true" /> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.bsc.maven</groupId> <artifactId>maven-processor-plugin</artifactId> <version>2.1.0</version> <executions> <execution> <id>process</id> <goals> <goal>process</goal> </goals> <phase>generate-sources</phase> <configuration> <compilerArguments>-Aopenjpa.source=8 -Aopenjpa.metamodel=true</compilerArguments> <processors> <processor>org.apache.openjpa.persistence.meta.AnnotationProcessor6</processor> </processors> <outputDirectory>target/generated-sources/metamodel</outputDirectory> <outputClassDirectory>target/metamodel/classes</outputClassDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>target/generated-sources/metamodel</source> </sources> </configuration> </execution> </executions> </plugin> <!-- The JBoss AS plugin deploys your war to a local JBoss EAP container --> <!-- To use, run: mvn package jboss-as:deploy --> <plugin> <groupId>org.jboss.as.plugins</groupId> <artifactId>jboss-as-maven-plugin</artifactId> <version>${version.jboss.maven.plugin}</version> <configuration> <hostname>${hostname}</hostname> <port>${port}</port> <username>${username}</username> <password>${password}</password> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classifier>ejb-client</classifier> <includes> <include>com/company1/PointDev*</include> </includes> <excludes> <exclude>**/*.dnx</exclude> </excludes> </configuration> </execution> </executions> </plugin> </plugins> <!-- </pluginManagement> --> </build> <profiles> <profile> <id>POSTGRES</id> <activation> <property> <name>databaseType</name> <value>POSTGRES</value> </property> </activation> <build> <finalName>${project.artifactId}</finalName> <resources> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>Db2/*</exclude> <exclude>Oracle/*</exclude> <exclude>Postgres/*</exclude> </excludes> </resource> </resources> <plugins> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>src/main/resources/</outputDirectory> <resources> <resource> <directory>src/main/resources/Postgres</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>jbossas-remote-7</id> <build> <plugins> <plugin> <groupId>org.jboss.as.plugins</groupId> <artifactId>jboss-as-maven-plugin</artifactId> <version>${version.jboss.maven.plugin}</version> <configuration> <hostname>${hostname}</hostname> <port>${port}</port> <username>${username}</username> <password>${password}</password> <domain> <server-groups> <server-group>${domain}</server-group> </server-groups> </domain> </configuration> </plugin> </plugins> </build> </profile> <profile> <!-- The default profile skips all tests, though you can tune it to run just unit tests based on a custom pattern --> <!-- Seperate profiles are provided for running all tests, including Arquillian tests that execute in the specified container --> <id>default</id> <activation> <property> <name>!default</name> </property> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${version.surefire.plugin}</version> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> </profile> <profile> <!-- An optional Arquillian testing profile that executes tests in your JBoss EAP instance --> <!-- This profile will start a new JBoss EAP instance, and execute the test, shutting it down when done --> <!-- Run with: mvn clean test -Parq-jbossas-managed --> <id>arq-jbossas-managed</id> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>${version.surefire.plugin}</version> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> <dependencies> <!-- https://mvnrepository.com/artifact/org.jboss.arquillian.container/arquillian-container-spi --> <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-container-spi</artifactId> <version>1.0.0.CR6</version> </dependency> <dependency> <groupId>org.jboss.ejb3</groupId> <artifactId>jboss-ejb3-api</artifactId> <version>3.1.0</version> <scope>test</scope> </dependency> </dependencies> </profile> <profile> <!-- An optional Arquillian testing profile that executes tests in a remote JBoss EAP instance --> <!-- Run with: mvn clean test -Parq-jbossas-remote --> <id>arq-jbossas-remote</id> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>${version.surefire.plugin}</version> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-remote</artifactId> <version>7.2.0.Final</version> <scope>test</scope> </dependency> </dependencies> </profile> <!-- Activate JBoss Product Maven repository --> <profile> <id>jboss-product-repository</id> <activation> <property> <name>!jboss-product-repository</name> </property> </activation> <repositories> <repository> <id>jboss-products-ga-repo</id> <url>http://maven.repository.redhat.com/techpreview/all/</url> </repository> </repositories> </profile> <profile> <id>windows</id> <activation> <os> <family>windows</family> </os> </activation> <properties> <shell.ext>bat</shell.ext> </properties> </profile> <profile> <id>unix</id> <activation> <os> <family>unix</family> </os> </activation> <properties> <shell.ext>sh</shell.ext> </properties> </profile> <profile> <id>mac</id> <activation> <os> <family>mac</family> </os> </activation> <properties> <shell.ext>sh</shell.ext> </properties> </profile> <profile> <id>wildfly-remote</id> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>${version.surefire.plugin}</version> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> <dependencies> <!-- https://mvnrepository.com/artifact/org.jboss.shrinkwrap.resolver/shrinkwrap-resolver-api-maven --> <dependency> <groupId>org.jboss.shrinkwrap.resolver</groupId> <artifactId>shrinkwrap-resolver-api-maven</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.wildfly</groupId> <artifactId>wildfly-arquillian-container-remote</artifactId> <version>${version.org.wildfly}</version> <scope>test</scope> </dependency> <!-- <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.4.1208-jdbc42-atlassian-hosted</version> </dependency> --> </dependencies> </profile> </profiles> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.8.1</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>3.0.1</version> <configuration> <xmlOutput>true</xmlOutput> <effort>Max</effort> <failOnError>false</failOnError> <threshold>Low</threshold> <xmlOutputDirectory>target/site</xmlOutputDirectory> </configuration> </plugin> </plugins> </reporting>