-->
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.  [ 6 posts ] 
Author Message
 Post subject: hbm2ddl org.hibernate.MappingExcpetion
PostPosted: Fri Apr 04, 2008 1:07 pm 
Newbie

Joined: Fri Apr 04, 2008 12:57 pm
Posts: 4
i'm trying to go from annotations to a database schema, and i'm getting an org.hibernate.MappingException.

here's my hibernate.cfg.xml

Code:
<!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="connection.url">${hibernate.connection.url}</property>
   <property name="connection.username">${hibernate.connection.username}</property>
   <property name="connection.password">${hibernate.connection.password}</property>

   <property name="connection.driver_class">${hibernate.connection.driver_class}</property>
   <property name="connection.autoReconnect">true</property>
   <property name="connection.autoReconnectForPools">true</property>
   <property name="connection.is-connection-validation-required">true</property>
   <property name="dialect">${hibernate.dialect}</property>
   <property name="show_sql">${hibernate.show.sql}</property>

   <mapping class="x.y.Application" />
   <mapping class="x.y.ApplicationEvent" />
   <mapping class="x.y.ApplicationProbe" />
</session-factory>
</hibernate-configuration>


my build.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="myTest" basedir=".">

   <property name="lib.dir" value="../../../WebContent/WEB-INF/lib"/>
   <property name="build.dir" value="build"/>
   <property name="my.dir" value="/e2e/src/main/java/" />
   
   <property name="proj.shortname" value="helloworld-jpa"/>
   
   
   <!-- Classpath declaration -->
    <path id="project.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
            <include name="**/*.zip"/>
        </fileset>
    </path>
   
     <!-- Hibernate Tools import -->
    <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" classpath="${build.dir}"/>
   
    <hibernatetool destdir="${build.dir}">
      <annotationconfiguration configurationfile="hibernate.cfg.xml"/>
         <hbm2ddl drop="true" create="true" export="true" outputfilename="${proj.shortname}-ddl.sql" delimiter=";"/>
       <cfg2hbm/>
   </hibernatetool>
   
</project>


when i run my build.xml, i get
Code:
Buildfile: /Users/Wong/Documents/workspace-flex/e2e/src/main/resources/build.xml
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: cfg2hbm (Generates a set of hbm.xml files)
[hibernatetool] Apr 4, 2008 11:43:41 AM org.hibernate.cfg.annotations.Version <clinit>
[hibernatetool] INFO: Hibernate Annotations 3.2.1.GA
[hibernatetool] Apr 4, 2008 11:43:41 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.2
[hibernatetool] Apr 4, 2008 11:43:41 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] Apr 4, 2008 11:43:41 AM org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] Apr 4, 2008 11:43:41 AM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] Apr 4, 2008 11:43:41 AM org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml

BUILD FAILED
/resources/build.xml:22: org.hibernate.MappingException: Unable to load class declared as <mapping class="x.y.Application"/> in the configuration:

Total time: 1 second


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 05, 2008 11:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
your classes need to be in the classpath of the <hibernatetool> call.

see docs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 11:49 am 
Newbie

Joined: Fri Apr 04, 2008 12:57 pm
Posts: 4
the class path is in the reference to <hibernatetool> in :
Code:
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" classpath="${build.dir}"/>
   
    <hibernatetool destdir="${build.dir}">


and i also tried it with classpath in <hibernatetool>, but i'm still getting the same error. i could still be doing it incorrectly. any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 11:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
make sure you don't have overlapping class paths in those two.

don't include user classes in your hibernatetool taskdef. It messes up ant's classloading.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 1:17 pm 
Newbie

Joined: Fri Apr 04, 2008 12:57 pm
Posts: 4
if i use
Code:
<mapping package="x.y.model"/>

instead of
Code:
<mapping class="x.y.model.Application" />

it runs fine. but it doesn't seem to be reading my package, because the output file is empty.

and i assume the classpath location should be in reference to where my build.xml is correct?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 3:07 pm 
Newbie

Joined: Fri Apr 04, 2008 12:57 pm
Posts: 4
i was able to solve the problem. it was because in my classpath, i wasn't pointing to my WEB-INF/class directory. thanks.


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