I'm quite new to OpenJPA and wanted to run my application. I've made a main method and load the context XML there and fire up a transaction to run my servi开发者_开发技巧ce in. But when I run it I get a
org.apache.openjpa.persistence.ArgumentException: The type "class tld.myproject.domain.Entity" has not been enhanced.
I Google'd around and found that I'd need to add an enhancer, so I added the following to my command line:
-javaagent:/home/me/.m2/repository/org/apache/openjpa/openjpa/2.0.1/openjpa-2.0.1.jar
Now, I get
java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader): attempted duplicate class definition for name: "org/springframework/stereotype/Controller"
Perhaps it's just getting late and I don't have my head screwed right on, but, what on earth is going on here? What do I need to do to get my Spring Roo batch project running?
Cheers
Nik
PS, I should probably add that in my pom.xml Roo has defined an enhancer for the compile phase
You should probably use compile time enhancement instead of runtime enhancement with javaagent.
If you're using m2eclipse (you probably do) it would be enough to use something like:
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<properties>
<property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.H2Dictionary"/>
<!-- value="buildSchema" to runtime forward map the DDL SQL; value="validate" makes no changes to the database -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
<property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
</properties>
</persistence-unit>
and inside build section of your pom.xml you should have something like:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<includes>**/*.class</includes>
<excludes>**/*_Roo_*.class</excludes>
<addDefaultConstructor>true</addDefaultConstructor>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
<execution>
<id>test-enhancer</id>
<phase>test-compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>${openjpa.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
Please note that roo might generate different xml snippet that might not work (IIRC it uses different output directory).
After you clean your project classes should be enhanced.
精彩评论