Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.1.1
-
None
-
Win7 64-bit, javac 1.6.0_26, Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500), openjpa-maven-plugin 1.2
Description
I'm attempting to enhance via the maven plugin entities that are in src/test/java & that are compiled to target/test-classes. The persistence.xml file is also located under target/test-classes (since it comes from src/test/resources/META-INF/persistence.xml). Enhancement is failing because .../target/test-classes is not on the classpath that the enhancer uses (see trace below).
Steps to reproduce:
1. Create a Maven project that includes OpenJPA dependencies & the Maven OpenJPA plugin.
2. Create an @Entity class in src/test/java/org/example/entity/Foo.java. Note this is in src/test/java, not src/main/java.
3. Put a persistence.xml file in src/test/resources/META-INF/persistence.xml that names Foo as an entity:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="application"
transaction-type="RESOURCE_LOCAL">
<class>org.example.entity.Foo</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
</persistence>
4. Configure the openjpa-maven-plugin as below. Note phase is "process-test-classes" & classes argument is "${project.build.testOutputDirectory}".
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>enhancer</id>
<phase>process-test-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<configuration>
<classes>${project.build.testOutputDirectory}</classes>
</configuration>
</plugin>
5. Issue maven command "mvn -X clean test".
6. Suspicion of missing classpath element ".../target/test-classes" is further reinforced if you include the plugin argument <persistenceXmlFile> and set its value to "${project.build.testOutputDirectory}/META-INF/persistence.xml". Plugin then finds persistence.xml, but complains about not finding class Foo (which it can't because the plug-in doesn't include .../target/test-classes on the classpath at enhancement time).
MAVEN OUTPUT TRACE:
===================
[DEBUG] Configuring mojo 'org.codehaus.mojo:openjpa-maven-plugin:1.2:enhance' -->
[DEBUG] (f) addDefaultConstructor = true
[DEBUG] (f) classes = C:\Perforce\p4serv1.online.ea.com_1999\matthewadams_win7\nucleus\SANDBOX\madams\nextgen\shard-test-example\target\test-classes
[DEBUG] (f) compileClasspathElements = [C:\Perforce\p4serv1.online.ea.com_1999\matthewadams_win7\nucleus\SANDBOX\madams\nextgen\shard-test-example\target\classes, C:\Users\madams\.m2\repository\org\eclipse\persistence\javax.persistence\2.0.0\javax.persistence-2.0.0.jar, C:\Users\madams\.m2\repository\javax\validation\validation-api\1.0.0.GA\validation-api-1.0.0.GA.jar, C:\Users\madams\.m2\repository\org\hibernate\hibernate-validator\4.1.0.Final\hibernate-validator-4.1.0.Final.jar, C:\Users\madams\.m2\repository\org\slf4j\slf4j-api\1.6.2\slf4j-api-1.6.2.jar, C:\Users\madams\.m2\repository\org\springframework\spring-context-support\3.1.0.RC1\spring-context-support-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-beans\3.1.0.RC1\spring-beans-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-core\3.1.0.RC1\spring-core-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-asm\3.1.0.RC1\spring-asm-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-context\3.1.0.RC1\spring-context-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-aop\3.1.0.RC1\spring-aop-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar, C:\Users\madams\.m2\repository\org\springframework\spring-expression\3.1.0.RC1\spring-expression-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-orm\3.1.0.RC1\spring-orm-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-jdbc\3.1.0.RC1\spring-jdbc-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\org\springframework\spring-tx\3.1.0.RC1\spring-tx-3.1.0.RC1.jar, C:\Users\madams\.m2\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar, C:\Users\madams\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar, C:\Users\madams\.m2\repository\commons-dbcp\commons-dbcp\1.2.2\commons-dbcp-1.2.2.jar, C:\Users\madams\.m2\repository\commons-pool\commons-pool\1.3\commons-pool-1.3.jar, C:\Users\madams\.m2\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar, C:\Users\madams\.m2\repository\org\slf4j\slf4j-log4j12\1.6.2\slf4j-log4j12-1.6.2.jar, C:\Users\madams\.m2\repository\org\apache\openjpa\openjpa\2.1.1\openjpa-2.1.1.jar, C:\Users\madams\.m2\repository\commons-lang\commons-lang\2.4\commons-lang-2.4.jar, C:\Users\madams\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar, C:\Users\madams\.m2\repository\net\sourceforge\serp\serp\1.13.1\serp-1.13.1.jar, C:\Users\madams\.m2\repository\org\apache\geronimo\specs\geronimo-jms_1.1_spec\1.1.1\geronimo-jms_1.1_spec-1.1.1.jar, C:\Users\madams\.m2\repository\org\apache\geronimo\specs\geronimo-jta_1.1_spec\1.1.1\geronimo-jta_1.1_spec-1.1.1.jar, C:\Users\madams\.m2\repository\org\apache\derby\derby\10.8.1.2\derby-10.8.1.2.jar]
[DEBUG] (f) enforcePropertyRestrictions = false
[DEBUG] (f) forceMojoExecution = false
[DEBUG] (f) includes = */.class
[DEBUG] (f) project = MavenProject: org.example:shard-test:1.0.1.CI-SNAPSHOT @ C:\Perforce\p4serv1.online.ea.com_1999\matthewadams_win7\nucleus\SANDBOX\madams\nextgen\shard-test-example\pom.xml
[DEBUG] (f) skip = false
[DEBUG] (f) tmpClassLoader = false
[DEBUG] (f) toolProperties = {}
[DEBUG] – end configuration –
[INFO] [openjpa:enhance
]
[DEBUG] Added classpathElement URL file:/C:/Perforce/p4serv1.online.ea.com_1999/matthewadams_win7/nucleus/SANDBOX/madams/nextgen/shard-test-example/target/classes/
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/eclipse/persistence/javax.persistence/2.0.0/javax.persistence-2.0.0.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/hibernate/hibernate-validator/4.1.0.Final/hibernate-validator-4.1.0.Final.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/slf4j/slf4j-api/1.6.2/slf4j-api-1.6.2.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-context-support/3.1.0.RC1/spring-context-support-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-beans/3.1.0.RC1/spring-beans-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-core/3.1.0.RC1/spring-core-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-asm/3.1.0.RC1/spring-asm-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-context/3.1.0.RC1/spring-context-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-aop/3.1.0.RC1/spring-aop-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-expression/3.1.0.RC1/spring-expression-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-orm/3.1.0.RC1/spring-orm-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-jdbc/3.1.0.RC1/spring-jdbc-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/springframework/spring-tx/3.1.0.RC1/spring-tx-3.1.0.RC1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/cglib/cglib/2.2.2/cglib-2.2.2.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/commons-dbcp/commons-dbcp/1.2.2/commons-dbcp-1.2.2.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/commons-pool/commons-pool/1.3/commons-pool-1.3.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/apache/openjpa/openjpa/2.1.1/openjpa-2.1.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar
[DEBUG] Added classpathElement URL file:/C:/Users/madams/.m2/repository/org/apache/derby/derby/10.8.1.2/derby-10.8.1.2.jar
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
<openjpa-2.0.0-r422266:935683 fatal user error> org.apache.openjpa.util.MetaDataException: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.
at org.apache.openjpa.meta.MetaDataRepository.initializeMetaDataFactory(MetaDataRepository.java:1873)
at org.apache.openjpa.meta.MetaDataRepository.endConfiguration(MetaDataRepository.java:1854)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:507)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:432)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104)
at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:939)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4618)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4600)
at org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4570)
at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:725)
at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:710)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4565)
at org.codehaus.mojo.openjpa.AbstractOpenJpaEnhancerMojo.enhance(AbstractOpenJpaEnhancerMojo.java:136)
at org.codehaus.mojo.openjpa.AbstractOpenJpaEnhancerMojo.execute(AbstractOpenJpaEnhancerMojo.java:95)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Mon Oct 24 12:42:06 CDT 2011
[INFO] Final Memory: 32M/265M
[INFO] ------------------------------------------------------------------------