I am trying to enhance an Entity class coming from another Jar using maven plugin openjpa-maven-plugin
and unfortunately I didn't find a correct way to do it.
I have one class MyPojo
from module MyDomain
packaged in jar my-domain.jar
:
public class MyPojo {
private Long id;
...
}
In my second project MyJpa
packaging my-jpa.jar
, it depends on module my-domain.jar
, and Maven is configured to use Build Time OpenJPA Enhancer with the following:
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<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.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
</plugin>
and I am using an XML mapping orm.xml
declared in persistence.xml
:
...
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>META-INF/orm.xml</mapping-file>
...
and with the orm.xml that looks like :
<entity class="MyPojo" access="FIELD">
<table name="MYPOJO"/>
<attributes>
<id name="id">
<generated-value strategy="AUTO"/>
</id>
</attributes>
</entity>
Running mvn install
gives the following error :
This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent:
When I move the class MyPojo
into the project MyJpa
(instead of the project MyDomain), it works.
So my question is : what do I need to configure in order to be able to enhance at build time the class MyPojo
coming from an external Jar ?
what do I need to configure in order to be able to enhance at build time the class MyPojo coming from an external Jar ?
If I understand your question correctly, you can't enhance a class that lives inside of a jar at build time. If you want to enhance in this way, you need to unjar the class, enhance, then rejar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With