thecodecentre
thecodecentre

Reputation: 1

org.apache.maven.plugin.MojoExecutionException: The DataNucleus tool org.datanucleus.enhancer.DataNucleusEnhancer exited with a non-null exit code

When running maven build for Google App Engine I am getting a build error:

org.apache.maven.plugin.MojoExecutionException: The DataNucleus tool org.datanucleus.enhancer.DataNucleusEnhancer exited with a non-null exit code.

I am trying to get Datanucleus working with JDO and data enhancer.

I have followed instructions and have included the following in my pom.xml:

  <plugin>
  <groupId>org.datanucleus</groupId>
  <artifactId>datanucleus-maven-plugin</artifactId>
        <version>5.0.0-release</version>
        <configuration>
          <persistenceUnitName>transactions-optional</persistenceUnitName>
            <verbose>true</verbose>
        </configuration>
       <executions>
            <execution>
                <phase>process-classes</phase>
                <goals>
                    <goal>enhance</goal>
                </goals>
            </execution>
        </executions>
      <dependencies>
      <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>3.1.0-release</version>
        <scope>runtime</scope>
      </dependency>
          <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>3.1.0-release</version>
          </dependency>
        </dependencies>
    </plugin>

BTW this is working fine with Java 7 and no build tools. This is a new project with Java 8 and Maven. Getting same error when I run mvn -X datanucleus:enhance

Been stuck for days and have tried various iterations of the plugin config and suggestions on Stack Overflow but no luck. Any assistance would be appreciated.

Upvotes: 0

Views: 1233

Answers (1)

Vivek
Vivek

Reputation: 1125

See, Even I faced the same issue for days and finally realized small things can create big mess. Here you go, at the first instance refer to this link : http://www.datanucleus.org/products/accessplatform_3_0/jdo/maven.html

and use the correct mentioned versions. The problem is, you cannot just use any version of jdo-api, datanucleus-api-jdo & datanucleus-core. These have to be in sync. Please see below I am using :

<dependency>
        <groupId>javax.jdo</groupId>
        <artifactId>jdo-api</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jdo</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-api-jpa</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
     <groupId>org.apache.geronimo.specs</groupId>
     <artifactId>geronimo-jpa_2.0_spec</artifactId>
     <version>1.0</version>
   </dependency>
   <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine.orm</groupId>
        <artifactId>datanucleus-appengine</artifactId>
        <version>2.1.2</version>
    </dependency>

and plugin as :

<plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.maven.plugin.version}</version>
        </plugin>
        <plugin>
            <groupId>org.datanucleus</groupId>
            <artifactId>maven-datanucleus-plugin</artifactId>
            <version>3.2.0-m1</version>
            <configuration>
                <api>JDO</api>
                <log4jConfiguration>${basedir}/src/main/resources/META-INF/log4j.properties</log4jConfiguration>
                <props>${basedir}/datanucleus.properties</props>
                <verbose>true</verbose>
                <enhancerName>ASM</enhancerName>
                <fork>false</fork>
            </configuration>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.datanucleus</groupId>
                    <artifactId>datanucleus-core</artifactId>
                    <version>3.1.3</version>
                </dependency>
            </dependencies>
        </plugin>

Few more checks, make sure you have below in your pom :

<prerequisites>
    <maven>3.0</maven>
</prerequisites>

Lastly, run the maven install and see if the enhancer works ! Logs like :

 DataNucleus Enhancer (version 3.1.1) : Enhancement of classes.
 DataNucleus Enhancer completed with success for 2 classes. Timings : input=594 ms, enhance=46 ms, total=640 ms. Consult the log for full details
 [INFO] 
 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) --

I have just deployed after new migration changes and it supports the old datastore values in production and works like a charm !Hope it helps !

Upvotes: 1

Related Questions