-->
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.  [ 4 posts ] 
Author Message
 Post subject: An exception occurred while running exporter #2:hbm2java
PostPosted: Tue Nov 24, 2009 5:02 am 
Newbie

Joined: Fri Nov 20, 2009 12:40 pm
Posts: 4
Hi All,

I am trying to generate pojo from Mapping file.
But When i will ant from command line i am getting the following :-
Buildfile:build.xml run:
[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] org.hibernate.MappingException: Resource: src\Person.hbm.xml not found BUILD FAILED java.lang.NoClassDefFoundError: org/hibernate/MappingNotFoundException Total time: 0 seconds


When i am running with -verbose i am getting everything fine as below:-
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: build.xml
Detected Java version: 1.5 in: C:\bea10\jdk150_11\jre
Detected OS: Windows XP
parsing buildfile C:\test\build.xml with URI = file:///C:/test/build.xml
Project base dir set to: C:\test
BUILD SUCCESSFUL
Total time: 0 seconds


Please help me,I can't get what is going on-
I have a folder named test in C:\test
under that my folder st. is as follows:-
test-
|-src
|-Hibernate.cfg.xml
|-Person.hbm.xml
|-lib
|-build.xml


In lib I have all jar files.

My Build.xml is:-

<project name="test" basedir="." >
<path id="toolslib">
<path location="lib/hibernate-tools.jar" />
<path location="lib/hibernate3.jar" />
<path location="lib/freemarker.jar" />
<path location="lib/ojdbc14.jar" />
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib"/>
<target name="run" description="generate hibernate classes">
<hibernatetool destdir = "${basedir}/src">
<configuration configurationfile="${basedir}/src/hibernate.cfg.xml">
<fileset dir="${basedir}/src">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java jdk5="true"/>
</hibernatetool>
</target>
</project>


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>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:GOLDREF/GOLDREF@16.180.213.98:1521:star</property>
<property name="connection.username">GOLDREF</property>
<property name="connection.password">GOLDREF</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping resource="src\Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>


My Person.hbm.xml is:-

<?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>
<class name="Person" table="PERSON1">
<id name="id" column="PERSON_ID" type="int">
<generator class="increment"/>
</id>
<property name="age" type="int" column="PERSON_AGE"/>
<property name="firstname" type="java.lang.String" column="PERSON_FIRSTNAME"/>
<property name="lastname" type="java.lang.String" column="PERSON_LASTNAME"/>
<hibernate-mapping>


Please help me.......Thanks in advance


Top
 Profile  
 
 Post subject: Re: An exception occurred while running exporter #2:hbm2java
PostPosted: Tue Nov 24, 2009 5:05 am 
Newbie

Joined: Fri Nov 20, 2009 12:40 pm
Posts: 4
I would like to give the folder structure again:-
In test folder we have src folder,lib folder,bin folder,build.xml.
In src we have hibernate.cfg.xml and person.hbm.xml.
in lib all jars are included.


Top
 Profile  
 
 Post subject: Re: An exception occurred while running exporter #2:hbm2java
PostPosted: Tue Nov 24, 2009 6:31 am 
Newbie

Joined: Fri Nov 20, 2009 12:40 pm
Posts: 4
Now i am getting the following error:-

Buildfile: build.xml
run:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] Nov 24, 2009 4:00:06 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.3.2.GA
[hibernatetool] Nov 24, 2009 4:00:06 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] Nov 24, 2009 4:00:06 PM org.hibernate.cfg.Environment buildBytec
odeProvider
[hibernatetool] INFO: Bytecode provider name : javassist
[hibernatetool] Nov 24, 2009 4:00:06 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] Nov 24, 2009 4:00:06 PM org.hibernate.cfg.Configuration configur
e
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml
[hibernatetool] Nov 24, 2009 4:00:06 PM org.hibernate.cfg.Configuration addResou
rce
[hibernatetool] INFO: Reading mappings from resource : Person.hbm.xml
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Genera
tes a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingNotFoundException: resource: Person.hbm.xml
not found
[hibernatetool] A resource located at Person.hbm.xml was not found.
[hibernatetool] Check the following:
[hibernatetool]
[hibernatetool] 1) Is the spelling/casing correct ?
[hibernatetool] 2) Is Person.hbm.xml available via the classpath ?
[hibernatetool] 3) Does it actually exist ?

BUILD FAILED
C:\test\build.xml:19: org.hibernate.MappingNotFoundException: resource: Person.h
bm.xml not found

Total time: 0 seconds


Top
 Profile  
 
 Post subject: Re: An exception occurred while running exporter #2:hbm2java
PostPosted: Wed Dec 02, 2009 1:00 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi paramita,

have you tried using a forward slash in your Hibernate.cfg.xml when specifying the path to the mapping file?
Quote:
<mapping resource="src/Person.hbm.xml"/>


CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


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