-->
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: AntTask and SchemaExport
PostPosted: Wed Feb 16, 2005 6:20 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Hi!

I've beeen reading, browsing and searching the forum of all the posts concerning trouble with ANT and SchemaExport. It mostly comes down to CP-problems, and it seems that all posters make up their own, mostly home-made, solutions. I also see a lot of '?' about why it's working when they do things a particular way, and 'antipatterns' like putting some or another part of the CP that is required in the ANT_HOME is very common.

Now I've had a some hellish days with the SchemaExport task and ANT.
I won't describe all the error, missing classes and stuff I've seen, but it mostly comes down to either 'duplicate import'-errors OR 'class not found'.
I wish it could have been something in between. ;)

Well, my problem is clearly a CP issur, no doubt about that.
I have the following code structure:
C:/radius2/src, C:/radius2/bin, C:/onkcommons/src, C:/onkcommons/bin
The 'bin' directories hold the *.class and *.hbm.xml-files.

Now 'radius2' use some of 'onkcommons' classes. Nothing fancy, some interfaces etc.

I've really made an effort including the relevant classes in my ant task.
Classpath declaration:
Code:
<path id="schexp">
      <fileset refid="app.classes"/>
      <fileset refid="app.hbm.mapping"/>
      <fileset refid="project.commons.classpath"/>   
      <pathelement location="${src.home}/radius2/conf/log4j.properties"/>
      <pathelement location="C:/jdk/spring-framework-1.1.4/lib/log4j/log4j-1.2.9.jar"/>
      <pathelement location="C:/jdk/spring-framework-1.1.4/lib/jakarta-commons/commons-logging.jar"/>
      <path refid="hibernate.classpath"/>
      <path refid="driver.classpath"/>
   </path>


which all expands to:

Code:
-C:\src\radius2\bin\karolinska\onk\radius\dao\ApplicationDao.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\RoleDao.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\UnitDao.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\UserDao.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\impl\ApplicationDaoImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\impl\AuditInfoDaoImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\impl\RoleDaoImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\impl\UnitDaoImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\dao\impl\UserDaoImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\AbstractKeyedEntity.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Application.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Group.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Role.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Unit.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\User.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\support\AuditInfoBean.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\support\InternalRole.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\test\TestInternalRole.class
   -C:\src\radius2\bin\karolinska\onk\radius\logic\IRadiusBusinessService.class
   -C:\src\radius2\bin\karolinska\onk\radius\logic\RadiusBusinessServiceException.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\editor\GroupEditor.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\editor\InternalRoleEditor.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\editor\RoleEditor.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\editor\UnitEditor.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\AbstractRadiusForm.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\ApplicationForm.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\ApplicationFormController.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\ChangePasswordForm.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\ChangePasswordFormController.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\LoginForm.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\LoginFormController.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\RadiusController.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\UnitForm.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\UnitFormController.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\UserForm.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\form\UserFormController.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\service\IChangePasswordWebService.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\service\ILoginWebService.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\service\ILogoutWebService.class
   -C:
    \src\radius2\bin\karolinska\onk\radius\web\service\caucho\ChangePasswordHessianImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\service\caucho\LoginHessianImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\web\service\caucho\LogoutHessianImpl.class
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Application.hbm.xml
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Group.hbm.xml
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Role.hbm.xml
   -C:\src\radius2\bin\karolinska\onk\radius\domain\Unit.hbm.xml
   -C:\src\radius2\bin\karolinska\onk\radius\domain\User.hbm.xml
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainApplication.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainGroup.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainPerson.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainRole.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainSession.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainUnit.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\DomainUser.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\support\AuditInfo.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\support\AuditInfoBean.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\domain\support\AuditInfoDao.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\graph\PageViewCountData.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\hibernate\Entity.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\hibernate\HibernateQueryParameter.
    class
   -C:\src\onkcommons\bin\karolinska\onk\commons\hibernate\KeyedEntity.class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\dynobject\AttributeValueImpl.
    class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\dynobject\AttributeValueUserType.
    class
   -C:\src\onkcommons\bin\karolinska\onk\commons\hibernate\support\dynobject\Item.class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\dynobject\ItemAttributeValue.
    class
   -C:\src\onkcommons\bin\karolinska\onk\commons\hibernate\support\dynobject\ItemType.
    class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\dynobject\ItemTypeAttribute.
    class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\enumeration\PersistentCharacterEnum.
    class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\enumeration\PersistentEnum.
    class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\enumeration\PersistentIntegerEnum.
    class
   -C:
    \src\onkcommons\bin\karolinska\onk\commons\hibernate\support\enumeration\PersistentStringEnum.
    class
   -C:\src\onkcommons\bin\karolinska\onk\commons\system\TimedLogin.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\web\BaseMultiFormController.class
   -C:\src\onkcommons\bin\karolinska\onk\commons\web\DomainUserSession.class
   -C:\src\radius2\conf\log4j.properties
   -C:\jdk\spring-framework-1.1.4\lib\log4j\log4j-1.2.9.jar
   -C:\jdk\spring-framework-1.1.4\lib\jakarta-commons\commons-logging.jar
   -C:\jdk\hibernate-2.1.8\hibernate2.jar
   -C:\jdk\hibernate-2.1.8\lib\cglib-full-2.0.2.jar
   -C:\jdk\hibernate-2.1.8\lib\commons-collections-2.1.1.jar
   -C:\jdk\hibernate-2.1.8\lib\commons-lang-1.0.1.jar
   -C:\jdk\hibernate-2.1.8\lib\commons-logging-1.0.4.jar
   -C:\jdk\hibernate-2.1.8\lib\commons-pool-1.2.jar
   -C:\jdk\hibernate-2.1.8\lib\dom4j-1.4.jar
   -C:\jdk\hibernate-2.1.8\lib\ehcache-0.9.jar
   -C:\jdk\hibernate-2.1.8\lib\log4j-1.2.8.jar
   -C:\jdk\hibernate-2.1.8\lib\odmg-3.0.jar
   -C:\jdk\hibernate-extensions-2.1.3\tools\hibernate-tools.jar
   -C:\jdk\misc\driver\mysql-connector-java-3.0.8-stable-bin.jar



My schemaexport target:

Code:
<target name="schemaexport" description="Generates a database initialisation file from *.hbm.xml-files">
      <taskdef name="schemaexport"
         classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
         classpathref="schexp"/>
      <schemaexport
         properties="${hibernate.cfgfile}"
         quiet="yes"
         text="yes"
         drop="no"
         delimiter=";"
         output="${misc}\${app.name}_schema.sql">
         <fileset refid="app.hbm.mapping"/>
      </schemaexport>
   </target>



Additional:
Code:
<fileset id="app.hbm.mapping" dir="${appbin}">
      <include name="**/*.hbm.xml" />
      <exclude name="**/*.class"/>
   </fileset>


My hibernate.config file:

Code:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/radtest
hibernate.connection.username=
hibernate.connection.password=
hibernate.connection.pool_size=10
hibernate.statement_cache.size=25
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.cglib.use_reflection_optimizer=true



What more does ANT and the SchemaExport task need???
I feel that the schemaexport is a great tool, but judging from the many(!) and different ad-hoq solutions that people come up with, it is not only I that feel totally clueless in front of the same tool.
Any help or suggestions will be greatly appreciated!

Hibernate version: 2.1.8, extensions v. 2.1.3

Mapping documents: n/a

Code between sessionFactory.openSession() and session.close(): n/a

Full stack trace of one of the exceptions that occurs:
Code:
BUILD FAILED
java.lang.NoClassDefFoundError: karolinska/onk/commons/hibernate/KeyedEntity
        at org.apache.tools.ant.Project.executeTarget(Project.java:1246)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
Caused by: java.lang.NoClassDefFoundError: karolinska/onk/commons/hibernate/KeyedEntity
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:99)
        at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:175)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        ... 5 more
--- Nested Exception ---
java.lang.NoClassDefFoundError: karolinska/onk/commons/hibernate/KeyedEntity
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:99)
        at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:175)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)


Name and version of the database you are using: MySQL 4.x

The generated SQL (show_sql=true): n/a

Debug level Hibernate log excerpt: logging not working


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 6:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, we don't really provide support for Ant or J2SE here. Ant classpath problems are just not specific to Hibernate and we are not enough experts in Ant to resolve such issues in the forum.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 6:35 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
gavin wrote:
Well, we don't really provide support for Ant or J2SE here. Ant classpath problems are just not specific to Hibernate and we are not enough experts in Ant to resolve such issues in the forum.


Thanks for your point of view and taking the time to write, but I posted in the "Tools" section of the Hibernate forum, and as I (perhaps wrong) assume that "SchemaExport task" is (at least) loosely connected to Hibernate.

A forum is a place to share experience and tips and tricks, and I was perhaps hoping for that more than regular "support", which I realize you cannot give.

Thanks again.


Top
 Profile  
 
 Post subject: Solved
PostPosted: Wed Feb 16, 2005 8:00 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Hi again!

To add to the '?'-solutions of this problem:

As I changed all the <fileset>-tags in the task CP to <pathelement path=".."> it works inside Eclipse at least.
You will also have to add the log4j.jar to the Eclipse-ANT_HOME through "Settings..->ANT"

Comand-line doesn't work still.

Code:
<path id="schexp">
      <!--fileset refid="app.classes"/>
      <fileset refid="app.hbm.mapping"/-->
      <pathelement path="${src.home}/radius2/bin" />
      <pathelement path="${src.home}/onkcommons/bin" />
      <!--fileset refid="project.commons.classpath"/-->
      <pathelement location="${src.home}/radius2/conf/log4j.properties"/>
      <pathelement location="C:/jdk/spring-framework-1.1.4/lib/log4j/log4j-1.2.9.jar"/>
      <pathelement location="C:/jdk/spring-framework-1.1.4/lib/jakarta-commons/commons-logging.jar"/>
      <path refid="hibernate.classpath"/>
      <path refid="driver.classpath"/>
   </path>


ANT works in mysterious ways...


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.