XML-less @Configuration (no persistence.xml) and openjpa-maven-plugin

606 Views Asked by At

Trying to convert my app (spring + jpa) to spring's annotation based @Configuration and get rid of spring app context xml and persistence.xml. All good except openjpa-maven-plugin 2.2.2 i use for build time class enhancement won't work without persistence.xml throwing the error:

[ERROR] Failed to execute goal org.apache.openjpa:openjpa-maven-plugin:2.2.2:enhance (enhancer) on project myapp: Execution enhancer of goal org.apache.openjpa:openjpa-maven-plugin:2.2.2:enhance failed: 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 or attributes of the task's nested element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.

plugin's configuration is:

      <configuration>
           <includes>**/business/model/*.class</includes>
           <addDefaultConstructor>true</addDefaultConstructor>
           <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
      </configuration>

It works, however, with persistence.xml existing but containing nothing but empty persistence units (i have 3 of them):

<persistence-unit name="pu1" transaction-type="RESOURCE_LOCAL">
</persistence-unit>

<persistence-unit name="pu2" transaction-type="RESOURCE_LOCAL">
</persistence-unit>

<persistence-unit name="pu3" transaction-type="RESOURCE_LOCAL">
</persistence-unit>

So the only information openjpa-maven-plugin may possibly get from this is persistence-unit names, if it even actually needs them.

Any way to implement build time openjpa class enhancement without persistence.xml?

0

There are 0 best solutions below