-->
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.  [ 2 posts ] 
Author Message
 Post subject: need help using hibernate ant task (ant newbie)
PostPosted: Thu Apr 29, 2004 11:32 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
im still new to ant and havent been able to get the tasks going,

error:
Buildfile: build.xml

init:

compile:
[javac] Compiling 14 source files to C:\Documents and Settings\x\Desktop\o2\build\WEB-INF\classes

create-db-tables:
[schemaexport] - Hibernate 2.1.2
[schemaexport] - hibernate.properties not found
[schemaexport] - using CGLIB reflection optimizer
[schemaexport] - Mapping file: C:\Documents and Settings\x\Desktop\o2\build\WEB-INF\classes\hibernateMappings\User.hbm.xml
[schemaexport] - Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: persistent class [o2.model.User] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:84)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:401)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:338)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:365)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:669)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:220)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
[schemaexport] Caused by: java.lang.ClassNotFoundException: o2.model.User
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1187)
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1128)
[schemaexport] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:998)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
[schemaexport] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
[schemaexport] at java.lang.Class.forName0(Native Method)
[schemaexport] at java.lang.Class.forName(Class.java:141)
[schemaexport] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:86)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
[schemaexport] ... 16 more
[schemaexport] - Could not configure datastore from file: C:\Documents and Settings\x\Desktop\o2\build\WEB-INF\classes\hibernateMappings\User.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: persistent class [o2.model.User] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:84)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:171)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:401)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:338)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:365)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:669)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:220)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
[schemaexport] Caused by: java.lang.ClassNotFoundException: o2.model.User
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1187)
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1128)
[schemaexport] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:998)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
[schemaexport] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
[schemaexport] at java.lang.Class.forName0(Native Method)
[schemaexport] at java.lang.Class.forName(Class.java:141)
[schemaexport] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:86)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
[schemaexport] ... 16 more

my build.xml

<project name="o2" default="compile" basedir=".">
<property name="classes.dir" location="build/WEB-INF/classes/"/>
<property name="lib.dir" location="lib/"/>

<property name="src.dir" location="src/"/>
<property name="src.java.dir" location="${src.dir}/java/"/>
<property name="src.test.dir" location="${src.dir}/test/"/>
<property name="src.webapp.dir" location="${src.dir}/webapp/"/>

<property name="build.dir" location="build/"/>
<property name="build.java.dir" location="${build.dir}/java/"/>
<property name="build.test.dir" location="${build.dir}/test/"/>


<path id="classpath">
<fileset dir="${lib.dir}"/>
</path>


<target name="create-db-tables" depends="compile"
description="create database tables">
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<path refid="classpath"/>
</classpath>
</taskdef>

<schemaexport quiet="no" text="no" drop="no" delimiter=";" output="create-tables.sql">
<fileset dir="${classes.dir}" includes="**/*.hbm.xml"/>
</schemaexport>
</target>


<target name="init">
<tstamp/>
<mkdir dir="${classes.dir}"/>
</target>

<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" debug="on"/>

<copy todir="${classes.dir}">
<fileset dir="${src.java.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>

<target name="clean">
<delete dir="${build.dir}"/>
</target>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 10:27 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
This has been answered many times on the forum.

Include your compiled classes in the classpath ie>

Code:
<taskdef name="schemaexport"
    classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
    <classpath>
        <path refid="classpath"/>
        <pathelement location="${classes.dir}"/>
    </classpath>
</taskdef>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.