DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCMAVEN-20
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Unassigned
Reporter: Arjun Balla
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Tools : Maven plugin

Problem in outputting ddl to a file using maven plugin

Created: 15/Jun/11 09:53 PM   Updated: 17/Jun/11 05:16 PM   Resolved: 16/Jun/11 07:38 AM
Component/s: None
Affects Version/s: 3.0.0.m2
Fix Version/s: None

Environment:
Apache Maven 3.0.2
JDK 1.6.0_23
Windows 7

Datastore: MySQL
Severity: Production

 Sub-Task Progress: 
  • Sub-Tasks:
  • All
  • Open

 Description  « Hide
I think the property to output ddl should be "ddlFile" and not "outputFile".
The Schema Tool documentation says it should be outputFile.
May I request you to please update the documentation.

http://www.datanucleus.org/products/accessplatform/rdbms/schematool.html#maven2

Also it will be nice to update sample pom as a lot of code is being refactored from 2.x.x to 3.x.x

For example the the below maven script will give the error.
============================
<build>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>2.2.0-release</version>
<configuration>
<log4jConfiguration>${basedir}/src/main/resources/log4j/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
<props>${basedir}/src/main/resources/jdo/db.properties</props>
<verbose>true</verbose>
<metadataDirectory>${basedir}/src/main/resources/jdo</metadataDirectory>
<ddlFile>${basedir}/src/main/resources/ddl/com.epaas.manager.model.ddl</ddlFile>
<log4jConfiguration>${basedir}/src/main/resources/log4j/log4j.properties</log4jConfiguration>
<completeDdl>true</completeDdl>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
<goal>schema-create</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
============================
[ERROR] --------------------
[ERROR] Standard error from the DataNucleus tool + org.datanucleus.store.rdbms.SchemaTool :
[ERROR] --------------------
[ERROR] java.lang.NoClassDefFoundError: org/datanucleus/store/rdbms/SchemaTool
Caused by: java.lang.ClassNotFoundException: org.datanucleus.store.rdbms.SchemaTool
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.datanucleus.store.rdbms.SchemaTool. Program will exit.
Exception in thread "main"


This is because the resolved depenedencies by maven are as below and SchemaTool (package is also changed) is part of datanuclues-core in 3.x.x which was part of datanuclues-rdbms in 2.2.x.

pluginArtifacts = [
 org.datanucleus:maven-datanucleus-plugin:maven-plugin:2.2.0-release:
 org.datanucleus:datanucleus-core:jar:3.0.0-m4:runtime
 org.datanucleus:datanucleus-enhancer:jar:3.0.0-m3:runtime
 javax.jdo:jdo-api:jar:3 .1-SNAPSHOT-20110319:runtime
 javax.transaction:transaction-api:jar:1.1:runtime
 org.datanucleus:datanucleus-rdbms:jar:3 .0.0-m3:runtime
 org.datanucleus:datanucleus-jpa:jar:2.1.7:runtime
 org.apache.geronimo.specs:geronimo-jpa_2.0_spec:jar: 1.0:runtime
 asm:asm:jar:3.3.1:runtime
 org.codehaus.plexus:plexus-utils:jar:1.2:compile
 junit:junit:jar:3.8.1:compile
]

Even if latest version of maven plugin 3.0.0-m2 is used, it will give the below error (intially I had no clue).
This is because the trasitive dependecy on datanuclues-rdbms is removed in 3.x.x.


SEVERE: Error creating NucleusContext
There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in
your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanu
cleus.storeManagerType"
org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "jdbc". Make sure that you h
ave put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you
also need to provide persistence property "datanucleus.storeManagerType"
        at org.datanucleus.NucleusContext.createStoreManagerForProperties(NucleusContext.java:476)
        at org.datanucleus.NucleusContext.initialise(NucleusContext.java:257)
        at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:561)
        at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:253)

We need to add the following to make it work.
============================
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>3.0.0-m4</version>
</dependency>
============================

The complete sample pom for mysql could be
============================
<dependencies>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>3.0.0-m3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.5</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>3.0.0-m4</version>
</dependency>
</dependencies>
<build>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.0.0-m2</version>
<configuration>
<log4jConfiguration>${basedir}/src/main/resources/log4j/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
<props>${basedir}/src/main/resources/jdo/db.properties</props>
<verbose>true</verbose>
<metadataDirectory>${basedir}/src/main/resources/jdo</metadataDirectory>
<ddlFile>${basedir}/src/main/resources/ddl/com.epaas.manager.model.ddl</ddlFile>
<log4jConfiguration>${basedir}/src/main/resources/log4j/log4j.properties</log4jConfiguration>
<completeDdl>true</completeDdl>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
<goal>schema-create</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
============================

Andy Jefferson added a comment - 16/Jun/11 07:38 AM
You refer to a doc for DN 2.2, and indeed the option there is called "outputFile". In DN 3.x it is obviously changed to "ddlFile" as per
http://www.datanucleus.org/servlet/jira/browse/NUCMAVEN-18. So no I don't see the issue. Obviously there may be some other thing you had in mind ...

Andy Jefferson made changes - 16/Jun/11 07:38 AM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Resolution Won't Fix [ 2 ]
Andy Jefferson made changes - 17/Jun/11 05:16 PM
Status Resolved [ 5 ] Closed [ 6 ]