Hello -
I am new to hibernate and have been working through the docs and trying things as I go. I have gotten hibernate 2.1 setup with jBoss 3.2.2 as in 66.html and have added the xdoclet tags and ant tasks.
When running the hibernateSar target it generates the *.hbm.xml correctly. However, when the schemaexport runs it blows up. I have the ant scripts and output below
Code:
<!-- =================================================================== -->
<!-- generates the hibernate HBM.XML files and SAR descriptor -->
<!-- =================================================================== -->
<target name="hibernate" description="Generates Hibernate class descriptor files." depends="build">
<taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask">
<classpath>
<fileset dir="${custom.lib}">
<include name="*.jar" />
<include name="xdoclet-1.2b4.jar" />
<include name="xdoclet-hibernate-module-1.2b4.jar" />
<include name="xdoclet-xdoclet-module-1.2b4.jar" />
<include name="xjavadoc-1.0.jar" />
</fileset>
</classpath>
</taskdef>
<!-- Execute the hibernatedoclet task -->
<hibernatedoclet destdir="${build.resources}/sar/hibernate"
excludedtags="@version,@author,@todo,@see,@desc"
addedtags="@xdoclet-generated at ${TODAY}@copyright foobar, Inc.,@author Jason Pratt,@version ${version}"
force="${xdoclet.force}"
mergedir="${build.resources}/sar/hibernate"
verbose="true">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<hibernate version="2.0" />
<jbossservice destdir="${jboss.dir}"
serviceName="Hibernate"
jndiName="${hibernate.jndi.name}"
dataSource="${hibernate.datasource.name}"
dialect="${hibernate.dialect}"
useOuterJoin="true"
transactionManagerStrategy="net.sf.hibernate.transaction.JBossTransactionManagerLookup"
transactionStrategy="net.sf.hibernate.transaction.JTATransactionFactory"
userTransactionName="UserTransaction" />
</hibernatedoclet>
</target>
<!-- =================================================================== -->
<!-- Hibernate SAR build -->
<!-- =================================================================== -->
<target name="hibernateSar" depends="hibernate">
<jar destfile="${jboss.dir}/hibernateStartup.sar">
<!-- Get the generated hbm.xml files -->
<fileset dir="${build.resources}/sar/hibernate">
<include name="**/*.hbm.xml" />
</fileset>
<fileset dir="${custom.lib}">
<include name="dom4j.jar"/>
<include name="ehcache.jar"/>
</fileset>
<metainf dir="${jboss.dir}">
<include name="jboss-service.xml" />
</metainf>
</jar>
<!-- Generate a schema DDL -->
<antcall target="hibernate_schemaexport" />
</target>
<!-- =================================================================== -->
<!-- Generate the database creation scripts from the Hibernate schema. -->
<!-- =================================================================== -->
<target name="hibernate_schemaexport">
<taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<fileset dir="${hibernate}">
<include name="hibernate2.jar" />
</fileset>
<fileset dir="${hibernate}/lib">
<include name="cglib-asm.jar" />
<include name="commons-collections.jar" />
<include name="commons-beanutils.jar" />
<include name="commons-lang.jar" />
<include name="commons-logging.jar" />
<include name="dom4j.jar" />
<include name="jaas.jar" />
<include name="jcs.jar" />
<include name="jdbc2_0-stdext.jar" />
<include name="dom4j.jar" />
<include name="jaas.jar" />
<include name="jcs.jar" />
<include name="jdbc2_0-stdext.jar" />
<include name="odmg.jar" />
</fileset>
<fileset dir="${jboss.dir}">
<include name="hibernateStartup.sar" />
</fileset>
</classpath>
</taskdef>
<echo message="drop-build.sql"/>
<schemaexport output="${mysql.dir}/drop-and-build.sql"
properties="${hibernate.props}"
quiet="yes"
delimiter=";"
text="yes">
<!-- -->
<fileset dir="${build.resources}/sar/hibernate">
<include name="**/*.hbm.xml" />
</fileset>
</schemaexport>
<echo message="drop.sql"/>
<schemaexport output="${mysql.dir}/drop.sql"
properties="${hibernate.props}"
quiet="yes"
drop="yes"
delimiter=";"
text="yes">
<fileset dir="${build.resources}/sar/hibernate">
<include name="**/*.hbm.xml" />
</fileset>
</schemaexport>
</target>
The output isCode:
Buildfile: build.xml
init:
hibernate:
[hibernatedoclet] (XDocletMain.start 47 ) Running <hibernate/>
[hibernatedoclet] Generating mapping file for omni.user.UserBean.
[hibernatedoclet] omni.user.UserBean
[hibernatedoclet] Generating mapping file for omni.user.AddressBean.
[hibernatedoclet] omni.user.AddressBean
[hibernatedoclet] Generating mapping file for omni.user.ProfileBean.
[hibernatedoclet] omni.user.ProfileBean
[hibernatedoclet] (XDocletMain.start 47 ) Running <jbossservice/>
[hibernatedoclet] Generating jboss service descriptor
hibernateSar:
[jar] Building jar: F:\projects\jboss\hibernateStartup.sar
hibernate_schemaexport:
[echo] drop-build.sql
[schemaexport] Jan 4, 2004 7:24:42 PM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: Hibernate 2.1 final
[schemaexport] Jan 4, 2004 7:24:42 PM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: hibernate.properties not found
[schemaexport] Jan 4, 2004 7:24:42 PM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: using CGLIB reflection optimizer
[schemaexport] Jan 4, 2004 7:24:42 PM net.sf.hibernate.cfg.Configuration addFile
[schemaexport] INFO: Mapping file: F:\projects\\build\resources\sar\hibernate\omni\user\AddressBean.hbm.xml
[schemaexport] Jan 4, 2004 7:24:43 PM net.sf.hibernate.cfg.Configuration add
[schemaexport] SEVERE: Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: persistent class [omni.user.AddressBean] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:207)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:186)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:132)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:193)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:341)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:309)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[schemaexport] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:397)
[schemaexport] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:143)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:341)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:309)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:609)
[schemaexport] at org.apache.tools.ant.Main.start(Main.java:196)
[schemaexport] at org.apache.tools.ant.Main.main(Main.java:235)
[schemaexport] Caused by: java.lang.ClassNotFoundException: omni.user.AddressBean
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1075)
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1036)
[schemaexport] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:925)
[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:75)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:78)
[schemaexport] ... 21 more
[schemaexport] Jan 4, 2004 7:24:43 PM net.sf.hibernate.cfg.Configuration addFile
[schemaexport] SEVERE: Could not configure datastore from file: F:\build\resources\sar\hibernate\omni\user\AddressBean.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: persistent class [omni.user.AddressBean] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:207)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:186)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:132)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:193)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:341)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:309)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[schemaexport] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:397)
[schemaexport] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:143)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:341)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:309)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:609)
[schemaexport] at org.apache.tools.ant.Main.start(Main.java:196)
[schemaexport] at org.apache.tools.ant.Main.main(Main.java:235)
[schemaexport] Caused by: java.lang.ClassNotFoundException: omni.user.AddressBean
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1075)
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1036)
[schemaexport] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:925)
[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:75)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:78)
[schemaexport] ... 21 more
I do not understand this section, I mean I do understand what is says but not why it is saying it. Code:
[schemaexport] Jan 4, 2004 7:24:42 PM net.sf.hibernate.cfg.Configuration addFile
[schemaexport] INFO: Mapping file: F:\build\resources\sar\hibernate\omni\user\AddressBean.hbm.xml
[schemaexport] Jan 4, 2004 7:24:43 PM net.sf.hibernate.cfg.Configuration add
[schemaexport] SEVERE: Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: persistent class [omni.user.AddressBean] not found
Do I still need to have a config file since I set it up as a jboss mbean for SchemaExport to work? Is it looking for the class in the same place as the hbm? The docs a very vague on how this works.
Any ideas of what I should look at or where?
regards,
Jason