-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: SchemaExportTask classpath nigthmare
PostPosted: Thu Jul 21, 2005 6:02 am 
Newbie

Joined: Thu Jul 21, 2005 5:37 am
Posts: 9
Location: Paris
I cannot get the schemaexport Ant task to work. Though I have defined a classpath in the schemaexport task definition, I still have NoClassDefFoundErrors for classes that are in the task's classpath.
Suprisingly, it seems to work if I add the jars referenced in the schemaexport task definition to the ant runtime classpath...
So I guess this is a classloader issue with the SchemaExportTask.

If not, what is the point of defining a custom classpath for the schemaexport task if you also have to define it in Ant's runtime classpath !


Here is some of my configuration info :

Hibernate 3.0.5
Ant 1.6.5 (launched from Eclipse 3.1)

Build.xml snippet :

Code:
   <target name="schemaExport">
      
      <taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
         <classpath>
            <path refid="project.classpath"/>
         </classpath>
      </taskdef>
      
      <schemaexport config="${test.res.dir}/hibernate.cfg.xml" quiet="no" text="no" drop="no" delimiter=";" output="${build.dir}/schema-export.sql">
      </schemaexport>
   
   </target>


Please note that project.classpath contains hibernate3.jar and its related librairies.

However, I got this execution failure :

Code:

java.lang.NoClassDefFoundError: org/hibernate/type/ImmutableType
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1225)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
   at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/type/ImmutableType
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
   at org.hibernate.type.TypeFactory.heuristicType(TypeFactory.java:194)
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:259)
   at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:128)
   at org.hibernate.mapping.Column.getSqlType(Column.java:172)
   at org.hibernate.mapping.Table.sqlCreateString(Table.java:263)
   at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:669)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:65)
   at org.hibernate.tool.hbm2ddl.SchemaExportTask.getSchemaExport(SchemaExportTask.java:210)
   at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:136)
   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.tools.ant.Target.performTasks(Target.java:369)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
   ... 6 more


I would really appreciate any help, as I am thinking about to abandon this way of generating my DB schema and instead doing it at runtime via the hbm2ddl.auto configuration property...


Thanks,

Gregory


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 6:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use the new ant tasks in hibernate tools - they should not have this issue.

tools.hibernate.org

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 3:27 am 
Newbie

Joined: Thu Jul 21, 2005 5:37 am
Posts: 9
Location: Paris
I have tried the Hibernate tools, with no more success. I still have to duplicate the classpath (in the task def and in the task itself) to avoid ClassNotFoundExceptions. It looks like there is a real issue with Ant class loader.

I'm bit short of time to investigate this more. So for now I'll stick to the automatic schema creation with the hbm2ddl.auto configuration property.


Anyway, tak vor din heljp, Max.


Gregory


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 4:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you put the classpath in hibernatetool taskdef it should definitly work.

the cvs version had a bug where you were forced to add in there instead of on the actual <hibernatetool> "call" but that is fixed.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.