Hi there!
Im experiencing problems using the Hibernate tools (the ant tool). With the help nbXDoclet of Netbeans IDE 5.5, I have created a HibernateBean(EJB3) and a Persistence-Unit. (Im using the JPA mapping configurations) The bean it seams to be well annotated. The persistence.xml file was created on the "./src/conf/" dir and after build it is placed on the "./build/web/WEB-INF/classes/META-INF/".
Next step was create a ant file to create the .hbm.xml mapping files. Everything went fine till here. I got an exception from the ant.
down there i leave the ant hbm2hbmxml.xml and persistence.xml file
Hibernate version:
Hibernate Core 3.2.2 GA
Hibernate EntityManager 3.2.1 GA
Hibernate Tools 3.2 beta 9
Mapping documents:
persistence.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd">
<persistence-unit name="ImmoServerUnit" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/immo" />
<property name="toplink.jdbc.user" value="root" />
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="toplink.jdbc.password" value="" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="toplink.ddl-generation" value="drop-and-create-tables" />
</properties>
</persistence-unit>
</persistence>
Ant tool file:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="hbm2hbmxml" default="all" basedir=".">
<target name="hbm2hbmxml" description="Generate .hbm.xml from .java files.">
<property name="build.dir" value="./build/web/WEB-INF/classes" />
<property name="config.dir" value="./src/conf" />
<path id="toolslib">
<path location="lib/hibernate-core/hibernate3.jar" />
<path location="lib/hibernate-core/commons-logging-1.0.4.jar" />
<path location="lib/hibernate-core/dom4j-1.6.1.jar" />
<path location="lib/hibernate-entitymanager/hibernate-annotations.jar" />
<path location="lib/hibernate-entitymanager/ejb3-persistence.jar" />
<path location="lib/hibernate-entitymanager/hibernate-entitymanager.jar" />
<path location="lib/hibernate-entitymanager/javassist.jar" />
<path location="lib/hibernate-entitymanager/jboss-archive-browsing.jar" />
<path location="lib/hibernate-tools/hibernate-tools.jar" />
<path location="lib/hibernate-tools/freemarker.jar" />
<path location="lib/mysql-connector-java-3.1.8-bin.jar" />
</path>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="toolslib" />
<hibernatetool destdir="${build.dir}/immoserver/persistence">
<jpaconfiguration persistenceunit="ImmoServerUnit" />
<classpath>
<path location="${build.dir}" />
</classpath>
<hbm2hbmxml />
</hibernatetool>
</target>
</project>
Full stack trace of ant exception:
hbm2hbmxml:
Executing Hibernate Tool with a JPA Configuration
1. task: hbm2hbmxml (Generates a set of hbm.xml files)
22/Fev/2007 9:04:17 org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.2.1.GA
22/Fev/2007 9:04:17 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.2.1.GA
22/Fev/2007 9:04:17 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.2
22/Fev/2007 9:04:17 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
22/Fev/2007 9:04:17 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
22/Fev/2007 9:04:17 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
To get the full stack trace run ant with -verbose
Persistence unit not found: 'ImmoServerUnit'.
C:\Documents and Settings\Marco\Os meus documentos\Programming\ImoOnline\ImmoWS\hbm2hbmxml.xml:25: Persistence unit not found: 'ImmoServerUnit'.
BUILD FAILED (total time: 0 seconds)
If any one could help me, i would appreciate
thans a lot
--ms