-->
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: hbm2java complains cant find class its generating
PostPosted: Thu Oct 22, 2009 4:31 pm 
Newbie

Joined: Thu Mar 15, 2007 1:22 am
Posts: 11
Environment:
HibernateTools-3.2.4.GA-R200905070146-H18
Hibernate-3.3.2GA
HSQLDB
Ant 1.6 and Ant 1.7

[hibernate.cfg.xml]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbc.JDBCDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost/icloud</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>

<mapping resource="com/polliard/icloud/Author.hbm.xml"/>
</session-factory>
</hibernate-configuration>

[Author.hbm.xml]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.polliard.icloud">
<class name="Author" table="AUTHOR">
<id name="authorID" column="ID">
<generator class="native"/>
</id>
<property name="authorName" column="NAME"/>
<property name="authorEmail" column="EMAIL"/>
</class>
</hibernate-mapping>

[build.xml]
<snip>

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

<target name="schemaexport" depends="compile, copymetafiles" description="Exports a generated schema to DB and file">
<hibernatetool destdir="${basedir}">
<classpath path="${build}"/>
<configuration configurationfile="${build}/hibernate.cfg.xml"/>
<hbm2ddl drop="true" create="true" export="true" outputfilename="${project.name}-ddl.sql" delimiter=";" format="true"/>
</hibernatetool>
</target>

<target name="pojoexport" description="Produces Java classes from XML mappings">
<hibernatetool destdir="${basedir}/src">
<configuration>
<fileset dir="${basedir}/src">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java jdk5="true"/>
</hibernatetool>
</target>
</snip>


This is the output from the ant build
[polliard@iron iCloud] ant pojoexport
Buildfile: build.xml

pojoexport:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Failed in building configuration when adding /Users/polliard/Workspace/iCloud/src/com/polliard/icloud/Author.hbm.xml
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from file /Users/polliard/Workspace/iCloud/src/com/polliard/icloud/Author.hbm.xml
[hibernatetool] org.hibernate.MappingException: class com.polliard.icloud.Author not found while looking for property: authorID
[hibernatetool] java.lang.ClassNotFoundException: com.polliard.icloud.Author
[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.

What am I doing wrong. It is supposed to be generating the .java files that will be used to make the very class its complaining about...
Thanks in advance for your help,

Thomas


Top
 Profile  
 
 Post subject: Re: hbm2java complains cant find class its generating
PostPosted: Tue Oct 27, 2009 8:15 pm 
Newbie

Joined: Thu Mar 15, 2007 1:22 am
Posts: 11
The Author.hbm.xml was my own creation (as minor as it was) trying to learn to use hibernate from some simple testing. The key thing was that the type wasnt being defined. The problem was resolved once I added the type="String" and so forth. Thanks for the feedback.


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.