-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernatetool ant task / jpaconfiguration gives ClassNotFoun
PostPosted: Fri Oct 23, 2009 7:47 am 
Newbie

Joined: Thu Oct 15, 2009 8:04 am
Posts: 6
Hi everyone,

I have a set of persistent classes, defined by JPA annotations. My persistence XML from META-INF looks like
Code:
<?xml version="1.0" encoding="UTF-8"?>

<persistence
   version="1.0"
   xmlns:p="http://java.sun.com/xml/ns/persistence"
   xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
   >
   <persistence-unit name="IdentityManagerPOJO" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
   </persistence-unit>
</persistence>


My definitions from the ant build file read:

Code:
   <path id="jpatoolslib">
      <path location="../3rdParty/Hibernate/Tool/org.hibernate.eclipse.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/bsh-core-2.0b4.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/tools/bsh-2.0b1.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/tools/freemarker.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/tools/hibernate-tools.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/tools/jtidy-r8-20060801.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/antlr-2.7.6.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/asm-attrs.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/asm.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/c3p0-0.9.1.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/cglib-2.1.3.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/commons-collections-2.1.1.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/commons-logging-1.0.4.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/concurrent-1.3.2.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/connector.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/dom4j-1.6.1.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/ehcache-1.2.3.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/hibernate3.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jaas.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/javassist.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jboss-cache.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jboss-common.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jboss-jmx.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jboss-system.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jdbc2_0-stdext.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jgroups-2.2.8.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/jta.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/log4j-1.2.15.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/oscache-2.1.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/proxool-0.8.3.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/hibernate/swarmcache-1.0rc2.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/annotations/ejb3-persistence.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/annotations/hibernate-annotations.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/annotations/hibernate-commons-annotations.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/annotations/hibernate-entitymanager.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/annotations/hibernate-search.jar" />
      <path location="../3rdParty/Hibernate/Tool/lib/annotations/lucene-core-2.2.0.jar" />
      
      <path location="./lib/POJODeploymentDeps/ojdbc14.jar" />
      <path location="./lib/POJODeploymentDeps/mysql-connector-java-5.1.5-bin.jar" />
      <path location="./lib/POJODeploymentDeps/jtds-1.2.2.jar" />
   </path>

   
   
   <taskdef   name="hibernatetool"
            classname="org.hibernate.tool.ant.HibernateToolTask"
            classpathref="jpatoolslib"
   />
   
   
   
   <target name="create-schema">
      <hibernatetool destdir="./database/ddl/SQLServer">
         <classpath>
            <path path="./dist/POJO/lib/" />
         </classpath>
      
         <property   key="hibernate.connection.driver_class"      value="net.sourceforge.jtds.jdbc.Driver"/>
         <property   key="hibernate.dialect"                  value="org.hibernate.dialect.SQLServerDialect"/>
      
         <!-- persistenceunit="IdentityManagerPOJO" -->
         <jpaconfiguration />

         <!-- list exporters here -->
         <hbm2ddl   export="false"
                  update="false"
                  drop="false"
                  create="true"
                  outputfilename="sqlserver.ddl"
                  delimiter=";"
                  format="false"
                  haltonerror="true"
                  />
      </hibernatetool>
   </target>      


I'm using only the classes bundled with the recent HibernateTools package (3.2.4.GA) plus a number of jars for database-specific dialect etc.

Now, when I run the create-schema task, the following Exception is raised.

Code:
[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] javax.persistence.PersistenceException: [PersistenceUnit: IdentityManagerPOJO] class or package not found
[hibernatetool] java.lang.ClassNotFoundException: com.entity.DataBlockCbeff
[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:\data\svndata\ABIS7\IM20\IMInterface\build\ddlBuild.xml:67: 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:57)
   at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
   at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
   at org.hibernate.tool.ant.Hbm2DDLExporterTask.createExporter(Hbm2DDLExporterTask.java:51)
   at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
   at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
   at org.apache.tools.ant.Task.perform(Task.java:348)
   at org.apache.tools.ant.Target.execute(Target.java:357)
   at org.apache.tools.ant.Target.performTasks(Target.java:385)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
   at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
   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:597)
   at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:43)
   ... 20 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: IdentityManagerPOJO] class or package not found
   at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1125)
   at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:905)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:792)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
   ... 25 more
Caused by: java.lang.ClassNotFoundException: com.entity.DataBlockCbeff
   at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
   at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1324)
   at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1072)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:247)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112)
   at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1041)
   at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1113)
   ... 29 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:597)
   at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:43)
   at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
   at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
   at org.hibernate.tool.ant.Hbm2DDLExporterTask.createExporter(Hbm2DDLExporterTask.java:51)
   at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
   at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
   at org.apache.tools.ant.Task.perform(Task.java:348)
   at org.apache.tools.ant.Target.execute(Target.java:357)
   at org.apache.tools.ant.Target.performTasks(Target.java:385)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
   at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
   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: javax.persistence.PersistenceException: [PersistenceUnit: IdentityManagerPOJO] class or package not found
   at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1125)
   at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:905)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:792)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
   ... 25 more
Caused by: java.lang.ClassNotFoundException: com.entity.DataBlockCbeff
   at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
   at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1324)
   at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1072)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:247)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112)
   at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1041)
   at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1113)
   ... 29 more

Total time: 907 milliseconds


Obviously, the hibernate tool does not find the class com.entity.DataBlockCbeff, but I do not understand why. DataBlockCbeff is one of the annotated entity classes. Since the program finds out the persistence unit name (IdentityManagerPOJO) which I have not explcitly specified, it must also find the persistence.xml file. And I have verified that it really uses the intended persistence.xml file by introducing some XML syntax error and seeing what happens. So I can expect that the tool find further classes that are at the same class path root. After all, since the name DataBlockCbeff is not specified anywhere and the tool tries to load the class, it must have already accessed its annotations and hence the class itself. This is really strange. I have no clue what I could be doing wrong here and I would appreciate any comments.

I'm not sure if this could matter, but the class in question has-been build time instrumented using org.hibernate.tool.instrument.cglib.InstrumentTask.

Thanks in advance,
-Rainer


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

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.