You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Makas Tzavellas <du...@gmail.com> on 2007/06/25 17:24:17 UTC

Using ant task mappingtool to generate tables

Hi everyone,

I'm trying to use mappingtool's ant task to generate tables for my 
entity classes. Problem is that it keeps complaining that my entity 
class does not have persistance metadata. The metadata is available as 
annotations in the entity class. Is it actually possible to generate 
tables using only the annotations in the entity class? Another thing is 
that I would like to avoid specifying the <class> element in the 
persistence.xml file as there are plans to dynamically drop new 
persistence classes while the application is running. Please advice!

This is the following error that I am getting.
Embedded error: <0.9.7-incubating fatal user error> 
org.apache.openjpa.util.MetaDataException: Type "class 
com.softbrands.subway.core.db.data.MessageEntity" does not have 
persistence metadata.

This is the entity class
@Entity
@Table(name="MESSAGES", schema="MESSAGES")
public class MessageEntity
{
    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) @Column(name="ID")
    private long m_Id;
   
    @Version
    @Column(name="OPTLOCK")
    private int m_Version; // This is used by JPA implementation to 
carry out optimistic locking.
   
    @Column(name="SIBLING_ID")
    private MessageEntity m_Sibling;
   
    @Column(name="STATUS")
    private String m_Status;
}



Sincerely,
Makas

RE: Using ant task mappingtool to generate tables

Posted by Pinaki Poddar <pp...@bea.com>.
   <classpath>
    <path refid="maven.runtime.classpath"/>
  </classpath>

 I think the <mappingtool> task does not expand refid. With
<mappingtool> Ant task try listing pathelements explictly in
<classpath>; that should work as well as <java
classname="org.....MappingTool>.

  Yes, I think it is a classpath-handling problem with tools invoked as
Ant task.


Pinaki Poddar
972.834.2865

-----Original Message-----
From: Makas Tzavellas [mailto:ducknight@gmail.com] 
Sent: Tuesday, June 26, 2007 12:26 AM
To: dev@openjpa.apache.org
Subject: Re: Using ant task mappingtool to generate tables

Hi Pinaki,

Thank you for your response. I am running the ant task from maven's ant
plugin. Here is the following snippet <mappingtool action="buildSchema"
sqlFile="test.sql">
  <classpath>
    <path refid="maven.runtime.classpath"/>
  </classpath>
  <fileset dir="${project.build.sourceDirectory}/">
    <include name="**/data/*.java"/>
  </fileset>
</mappingtool>

Here's the log and stacktrace of the error [INFO] Executing tasks
16  subway  TRACE  [main] openjpa.Runtime - Setting the following
properties from
"file:/C:/dev/softbrands/broker/subway/db/target/classes/META-INF/persis
tence.xml" 
into configuration: {openjpa.ConnectionUserName=sa,
openjpa.ConnectionPassword=, openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
openjpa.ConnectionURL=jdbc:derby:subway-test;create=true,
openjpa.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver,
openjpa.Id=subway}
422  subway  TRACE  [main] openjpa.MetaData - Using metadata factory
"org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@6833f2".
453  subway  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class 
"org.apache.openjpa.jdbc.sql.DerbyDictionary".
484  subway  INFO   [main] openjpa.Tool - Mapping tool running on type 
"class com.softbrands.subway.core.db.data.MessageEntity" with action
"buildSchema".
484  subway  TRACE  [main] openjpa.MetaData - Using metadata factory
"org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@717d91".
500  subway  TRACE  [main] openjpa.MetaData - Loading metadata for
"class com.softbrands.subway.core.db.data.MessageEntity" under mode
"[META][QUERY]".
500  subway  TRACE  [main] openjpa.MetaData - Scanning resource
"META-INF/orm.xml" for persistent types.
500  subway  TRACE  [main] openjpa.MetaData - parsePersistentTypeNames()
found [].
500  subway  TRACE  [main] openjpa.MetaData - Found 0 classes with
metadata in 0 milliseconds.
641  subway  TRACE  [main] openjpa.MetaData - Parsing class
"com.softbrands.subway.core.db.data.MessageEntity".
<0.9.7-incubating fatal user error>
org.apache.openjpa.util.MetaDataException: Type "class
com.softbrands.subway.core.db.data.MessageEntity" does not have
persistence metadata.
        at
org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676
)
        at
org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:74
2)
        at
org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:640)
        at
org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:1063)
        at
org.apache.openjpa.jdbc.ant.MappingToolTask.executeOn(MappingToolTask.ja
va:190)
        at
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:169)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntM
ojo.java:108)
        at
org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginMa
nager.java:420)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Default
LifecycleExecutor.java:539)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifec
ycle(DefaultLifecycleExecutor.java:480)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultL
ifecycleExecutor.java:459)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandle
Failures(DefaultLifecycleExecutor.java:311)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
DefaultLifecycleExecutor.java:278)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifec
ycleExecutor.java:143)
        at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:330)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:123)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
688  subway  TRACE  [main] openjpa.MetaData - Clearing metadata
repository "org.apache.openjpa.jdbc.meta.MappingRepository@38fff7".


*However* it does work if I invoke it as a java task <java
classname="org.apache.openjpa.jdbc.meta.MappingTool" 
classpathref="maven.runtime.classpath">
  <arg line="-sa build -sql test.sql
${project.build.sourceDirectory}/classes/com/softbrands/subway/core/db/d
ata/MessageEntity.java"/>
</java>

Could this really be a classpath problem?

Pinaki Poddar wrote:
> Hi,
>   
>> Is it actually possible to generate tables using only the annotations
>>     
> in the entity class?
> Yes.
>
> Please post the log and stack trace with <property name="openjpa.Log"
> value="DefaultLevel=TRACE"/>
> Also the snippet of the Ant target you are invoking for mappingtool.
> Please note that alternatively
> <java classname="org.apache.openjpa.jdbc.meta.MappingTool"> can be 
> used to invoke MappingTool from Ant And I find that somewhat easier to

> debug build/classpath problems.
>
>
>
> Pinaki Poddar
> 972.834.2865
>
> -----Original Message-----
> From: Makas Tzavellas [mailto:ducknight@gmail.com]
> Sent: Monday, June 25, 2007 10:24 AM
> To: dev@openjpa.apache.org
> Subject: Using ant task mappingtool to generate tables
>
> Hi everyone,
>
> I'm trying to use mappingtool's ant task to generate tables for my 
> entity classes. Problem is that it keeps complaining that my entity 
> class does not have persistance metadata. The metadata is available as

> annotations in the entity class. Is it actually possible to generate 
> tables using only the annotations in the entity class? Another thing 
> is that I would like to avoid specifying the <class> element in the 
> persistence.xml file as there are plans to dynamically drop new 
> persistence classes while the application is running. Please advice!
>
> This is the following error that I am getting.
> Embedded error: <0.9.7-incubating fatal user error>
> org.apache.openjpa.util.MetaDataException: Type "class 
> com.softbrands.subway.core.db.data.MessageEntity" does not have 
> persistence metadata.
>
> This is the entity class
> @Entity
> @Table(name="MESSAGES", schema="MESSAGES") public class MessageEntity
{
>     @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
> @Column(name="ID")
>     private long m_Id;
>    
>     @Version
>     @Column(name="OPTLOCK")
>     private int m_Version; // This is used by JPA implementation to 
> carry out optimistic locking.
>    
>     @Column(name="SIBLING_ID")
>     private MessageEntity m_Sibling;
>    
>     @Column(name="STATUS")
>     private String m_Status;
> }
>
>
>
> Sincerely,
> Makas
>
> Notice:  This email message, together with any attachments, may
contain information  of  BEA Systems,  Inc.,  its subsidiaries  and
affiliated entities,  that may be confidential,  proprietary,
copyrighted  and/or legally privileged, and is intended solely for the
use of the individual or entity named in this message. If you are not
the intended recipient, and have received this message in error, please
immediately return this by email and then delete it.
>
>   


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

Re: Using ant task mappingtool to generate tables

Posted by Makas Tzavellas <du...@gmail.com>.
Hi Pinaki,

Thank you for your response. I am running the ant task from maven's ant 
plugin. Here is the following snippet
<mappingtool action="buildSchema" sqlFile="test.sql">
  <classpath>
    <path refid="maven.runtime.classpath"/>
  </classpath>
  <fileset dir="${project.build.sourceDirectory}/">
    <include name="**/data/*.java"/>
  </fileset>
</mappingtool>

Here's the log and stacktrace of the error
[INFO] Executing tasks
16  subway  TRACE  [main] openjpa.Runtime - Setting the following 
properties from 
"file:/C:/dev/softbrands/broker/subway/db/target/classes/META-INF/persistence.xml" 
into configuration: {openjpa.ConnectionUserName=sa, 
openjpa.ConnectionPassword=, openjpa.Log=DefaultLevel=TRACE, Tool=INFO, 
openjpa.ConnectionURL=jdbc:derby:subway-test;create=true, 
openjpa.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver, 
openjpa.Id=subway}
422  subway  TRACE  [main] openjpa.MetaData - Using metadata factory 
"org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@6833f2".
453  subway  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class 
"org.apache.openjpa.jdbc.sql.DerbyDictionary".
484  subway  INFO   [main] openjpa.Tool - Mapping tool running on type 
"class com.softbrands.subway.core.db.data.MessageEntity" with action 
"buildSchema".
484  subway  TRACE  [main] openjpa.MetaData - Using metadata factory 
"org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@717d91".
500  subway  TRACE  [main] openjpa.MetaData - Loading metadata for 
"class com.softbrands.subway.core.db.data.MessageEntity" under mode 
"[META][QUERY]".
500  subway  TRACE  [main] openjpa.MetaData - Scanning resource 
"META-INF/orm.xml" for persistent types.
500  subway  TRACE  [main] openjpa.MetaData - parsePersistentTypeNames() 
found [].
500  subway  TRACE  [main] openjpa.MetaData - Found 0 classes with 
metadata in 0 milliseconds.
641  subway  TRACE  [main] openjpa.MetaData - Parsing class 
"com.softbrands.subway.core.db.data.MessageEntity".
<0.9.7-incubating fatal user error> 
org.apache.openjpa.util.MetaDataException: Type "class 
com.softbrands.subway.core.db.data.MessageEntity" does not have 
persistence metadata.
        at 
org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676)
        at 
org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:742)
        at 
org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:640)
        at 
org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:1063)
        at 
org.apache.openjpa.jdbc.ant.MappingToolTask.executeOn(MappingToolTask.java:190)
        at 
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:169)
        at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at 
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
        at 
org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:420)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:330)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:123)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at 
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
688  subway  TRACE  [main] openjpa.MetaData - Clearing metadata 
repository "org.apache.openjpa.jdbc.meta.MappingRepository@38fff7".


*However* it does work if I invoke it as a java task
<java classname="org.apache.openjpa.jdbc.meta.MappingTool" 
classpathref="maven.runtime.classpath">
  <arg line="-sa build -sql test.sql 
${project.build.sourceDirectory}/classes/com/softbrands/subway/core/db/data/MessageEntity.java"/>
</java>

Could this really be a classpath problem?

Pinaki Poddar wrote:
> Hi,
>   
>> Is it actually possible to generate tables using only the annotations
>>     
> in the entity class?
> Yes.
>
> Please post the log and stack trace with <property name="openjpa.Log"
> value="DefaultLevel=TRACE"/>
> Also the snippet of the Ant target you are invoking for mappingtool.
> Please note that alternatively
> <java classname="org.apache.openjpa.jdbc.meta.MappingTool"> can be used
> to invoke MappingTool from Ant 
> And I find that somewhat easier to debug build/classpath problems.
>
>
>
> Pinaki Poddar
> 972.834.2865
>
> -----Original Message-----
> From: Makas Tzavellas [mailto:ducknight@gmail.com] 
> Sent: Monday, June 25, 2007 10:24 AM
> To: dev@openjpa.apache.org
> Subject: Using ant task mappingtool to generate tables
>
> Hi everyone,
>
> I'm trying to use mappingtool's ant task to generate tables for my
> entity classes. Problem is that it keeps complaining that my entity
> class does not have persistance metadata. The metadata is available as
> annotations in the entity class. Is it actually possible to generate
> tables using only the annotations in the entity class? Another thing is
> that I would like to avoid specifying the <class> element in the
> persistence.xml file as there are plans to dynamically drop new
> persistence classes while the application is running. Please advice!
>
> This is the following error that I am getting.
> Embedded error: <0.9.7-incubating fatal user error>
> org.apache.openjpa.util.MetaDataException: Type "class
> com.softbrands.subway.core.db.data.MessageEntity" does not have
> persistence metadata.
>
> This is the entity class
> @Entity
> @Table(name="MESSAGES", schema="MESSAGES") public class MessageEntity {
>     @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
> @Column(name="ID")
>     private long m_Id;
>    
>     @Version
>     @Column(name="OPTLOCK")
>     private int m_Version; // This is used by JPA implementation to
> carry out optimistic locking.
>    
>     @Column(name="SIBLING_ID")
>     private MessageEntity m_Sibling;
>    
>     @Column(name="STATUS")
>     private String m_Status;
> }
>
>
>
> Sincerely,
> Makas
>
> Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
>
>   


RE: Using ant task mappingtool to generate tables

Posted by Pinaki Poddar <pp...@bea.com>.
Hi,
> Is it actually possible to generate tables using only the annotations
in the entity class?
Yes.

Please post the log and stack trace with <property name="openjpa.Log"
value="DefaultLevel=TRACE"/>
Also the snippet of the Ant target you are invoking for mappingtool.
Please note that alternatively
<java classname="org.apache.openjpa.jdbc.meta.MappingTool"> can be used
to invoke MappingTool from Ant 
And I find that somewhat easier to debug build/classpath problems.



Pinaki Poddar
972.834.2865

-----Original Message-----
From: Makas Tzavellas [mailto:ducknight@gmail.com] 
Sent: Monday, June 25, 2007 10:24 AM
To: dev@openjpa.apache.org
Subject: Using ant task mappingtool to generate tables

Hi everyone,

I'm trying to use mappingtool's ant task to generate tables for my
entity classes. Problem is that it keeps complaining that my entity
class does not have persistance metadata. The metadata is available as
annotations in the entity class. Is it actually possible to generate
tables using only the annotations in the entity class? Another thing is
that I would like to avoid specifying the <class> element in the
persistence.xml file as there are plans to dynamically drop new
persistence classes while the application is running. Please advice!

This is the following error that I am getting.
Embedded error: <0.9.7-incubating fatal user error>
org.apache.openjpa.util.MetaDataException: Type "class
com.softbrands.subway.core.db.data.MessageEntity" does not have
persistence metadata.

This is the entity class
@Entity
@Table(name="MESSAGES", schema="MESSAGES") public class MessageEntity {
    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name="ID")
    private long m_Id;
   
    @Version
    @Column(name="OPTLOCK")
    private int m_Version; // This is used by JPA implementation to
carry out optimistic locking.
   
    @Column(name="SIBLING_ID")
    private MessageEntity m_Sibling;
   
    @Column(name="STATUS")
    private String m_Status;
}



Sincerely,
Makas

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.