-->
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.  [ 3 posts ] 
Author Message
 Post subject: hbm2ddl gives java.lang.NoClassDefFoundError
PostPosted: Thu Nov 09, 2006 5:27 am 
Newbie

Joined: Wed Aug 18, 2004 10:44 am
Posts: 14
Hibernate version:
hibernate-3.2

Hi

Im trying to write an ant target which generates a ddl from annotated classes. The annotated classes are packaged in a jar-file entities.jar and works fine in my J2SE application.

Im running Ant in eclipse - here is a part of my build.xml that should do the magic:

---------------------------------------------------------

<path id="toolslib">
<path location="lib/hibernate-tools.jar" />
<path location="lib/hibernate3.jar" />
<path location="lib/freemarker.jar" />
<path location="lib/mysql-connector-java-3.0.14-production-bin.jar" />
<path location="lib/hibernate-annotations.jar" />
<path location="lib/ejb3-persistence.jar" />
<path location="lib/hibernate-entitymanager.jar" />
<path location="lib/jboss-archive-browsing.jar" />
<path location="lib/javaassist.jar" />
<path location="lib/commons-logging-1.0.4.jar" />
<path location="lib/dom4j-1.6.1.jar" />
</path>

<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" />

<target name="hibernate">
<hibernatetool destdir="${build.home}">
<jpaconfiguration persistenceunit="manager1"/>
<classpath>
<path location="${build.home}/WEB-INF/lib/entities.jar" />
</classpath>
<hbm2ddl export="false" outputfilename="sql.ddl"/>
</hibernatetool>
</target>

---------------------------------------------------------

When running the target hibernatetool -verbose the output is:

---------------------------------------------------------
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: C:\dev\weboverblik2\build.xml
parsing buildfile C:\dev\weboverblik2\build.xml with URI = file:///C:/dev/weboverblik2/build.xml
Project base dir set to: C:\dev\weboverblik2
[property] Loading C:\dev\weboverblik2\build.properties
dropping C:\dev\weboverblik2\lib\javaassist.jar from path as it doesn't exist
Build sequence for target(s) `hibernate' is [hibernate]
Complete build sequence is [hibernate, prepare, dev.compile, dev.entityjar, dev.war, deploy, reload, clean, dist.compile, install, database.drop, remove, javadoc, dist, compile.copyfiles, prepare.testdata, ]
hibernate:
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 2006-11-09 10:15:51 org.hibernate.ejb.Version <clinit>
[hibernatetool] INFO: Hibernate EntityManager 3.2.0.GA
[hibernatetool] 2006-11-09 10:15:51 org.hibernate.cfg.annotations.Version <clinit>
[hibernatetool] INFO: Hibernate Annotations 3.2.0.GA
[hibernatetool] 2006-11-09 10:15:51 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.0
[hibernatetool] 2006-11-09 10:15:51 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 2006-11-09 10:15:51 org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] 2006-11-09 10:15:51 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
[hibernatetool] java.lang.reflect.InvocationTargetException
[hibernatetool] java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.

BUILD FAILED
C:\dev\weboverblik2\build.xml:407: Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:42)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171)
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)
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.reflect.InvocationTargetException
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.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:28)
... 15 more
Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
at org.hibernate.ejb.packaging.JarVisitor.checkAnnotationMatching(JarVisitor.java:306)
at org.hibernate.ejb.packaging.JarVisitor.executeJavaElementFilter(JarVisitor.java:272)
at org.hibernate.ejb.packaging.JarVisitor.addElement(JarVisitor.java:233)
at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:48)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:215)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:253)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:229)
... 20 more
--- Nested Exception ---
java.lang.reflect.InvocationTargetException
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.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:28)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171)
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)
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: javassist/bytecode/ClassFile
at org.hibernate.ejb.packaging.JarVisitor.checkAnnotationMatching(JarVisitor.java:306)
at org.hibernate.ejb.packaging.JarVisitor.executeJavaElementFilter(JarVisitor.java:272)
at org.hibernate.ejb.packaging.JarVisitor.addElement(JarVisitor.java:233)
at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:48)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:215)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:253)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:229)
... 20 more

Total time: 1 second

---------------------------------------------------------

hbm2ddl fails because it cannot fint the the class javassist/bytecode/ClassFile. BUT the class is in the jar javaassist.jar as defined in the path.

Is this a bug? Or, is something else missing?

Regards,
René


Top
 Profile  
 
 Post subject: Fixed: Stupid error: spelling mistake
PostPosted: Thu Nov 09, 2006 5:40 am 
Newbie

Joined: Wed Aug 18, 2004 10:44 am
Posts: 14
It was a simple spelling mistake.

<path location="lib/javaassist.jar" />

must be:

<path location="lib/javassist.jar" />

+ adding a few more files and it works like a charm!

Regards,
René


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 5:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
:)

_________________
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.  [ 3 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.