My question is pretty straightforward. Given the following POM:
<build>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.0.0-release</version>
<configuration>
<log4jConfiguration>${basedir}/src/main/resources/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
<props>${basedir}/src/main/resources/datanucleus.properties</props>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>DataNucleus_Repos2</id>
<name>DataNucleus Repository</name>
<url>http://www.datanucleus.org/downloads/maven2</url>
</repository>
<repository> <!-- Required for transaction-api transitive dep -->
<id>Java_Net_LEGACY</id>
<name>Java.Net legacy</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>DataNucleus_2</id>
<url>http://www.datanucleus.org/downloads/maven2/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<scope>runtime</scope>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
And given that I have the files log4j.properties and datanucleus.properties in their expected place, when I run
mvn compile
I get (taken from datanucleus.log file)
19:36:11,297 (main) ERROR [DataNucleus.Enhancer] - DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors Error creating the MetaDataManager for API "JDO" : org.datanucleus.exceptions.NucleusException: Error creating the MetaDataManager for API "JDO" : at org.datanucleus.NucleusContext.getMetaDataManager(NucleusContext.java:964) at org.datanucleus.enhancer.DataNucleusEnhancer.getMetaDataManager(DataNucleusEnhancer.java:261) at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:716) at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:590) at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1390)
Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:681) at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:314) at org.datanucleus.NucleusContext.getMetaDataManager(NucleusContext.java:958) ... 4 more
Caused by: java.lang.NoSuchFieldError: supportsORM at org.datanucleus.api.jdo.metadata.JDOMetaDataManager.(JDOMetaDataManager.java:142) ... 11 more
I would like to enable logging to see what queries are being done by my application. A thing to note is that the enhancement works fine when removing log4j dependency from the POM. Of course, the log file doesn't get updated anymore, but the classes are enhanced.
Any idea related to the above behaviour will be greatly appreciated.