-->
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: mapping resource exception ...hbm.xml not found
PostPosted: Wed Jan 10, 2007 5:51 pm 
Newbie

Joined: Wed Jan 10, 2007 5:36 pm
Posts: 3
Hibernate version: 3.0

Mapping documents: hibernate.cfg.xml and hibernate.properties

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
org.apache.jasper.JasperException: org.hibernate.MappingNotFoundException: resource: /com/qpm/usergen/Item.hbm.xml not found
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.RuntimeException: org.hibernate.MappingNotFoundException: resource: /com/qpm/usergen/Item.hbm.xml not found
com.qpm.usergen.ConnectionFactory.<init>(Unknown Source)
com.qpm.usergen.ConnectionFactory.getInstance(Unknown Source)
com.qpm.usergen.ItemService.getItemList(Unknown Source)
org.apache.jsp.pages.AddItem_jsp._jspService(AddItem_jsp.java:115)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Name and version of the database you are using:
mySQL 5.0.27

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Hi Everyone,
I have been googling this problem all day and cannot
find a solution. i just created a new application
using struts 1.3.5 and hibernate3 with mySQL 5.0.27.

when i try to access my first jsp.. i get this exception
thrown... my configuration files look perfect... i dont
know what else i can check?

hibernate.cfg.xml:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:///test</property>
<property name="hibernate.connection.username">testuser</property>
<property name="hibernate.connection.password">testuser</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="/com/qpm/usergen/Item.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Item.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 auto-import="true"
package="com.qpm.usergen" >
<class name="com.qpm.usergen.Item" table="item">
<id name="id" column="id" type="java.lang.Long" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="name" column="name" type="java.lang.String" />
<property name="description" column="description" type="java.lang.String" />
</class>
</hibernate-mapping>

hibernate.properties:
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:///test
hibernate.connection.username testuser
hibernate.connection.password testuser


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 11:26 pm 
Beginner
Beginner

Joined: Mon Mar 27, 2006 5:25 am
Posts: 39
Location: India Hyderabad
uroojkhan,

modify in hibernate.cfg.xml file the following line
<mapping resource="com/qpm/usergen/Item.hbm.xml"/>


- Vinay Kumar

-----------------------
dont forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 11:30 am 
Newbie

Joined: Wed Jan 10, 2007 5:36 pm
Posts: 3
thanks vinay but that didnt help...

maybe its my build.xml??

any help would be greatly appreciated!! i really want
to use hibernate at my company here but i've been
stuck on getting things off the ground for two days now...

build.xml:
<project name="blank" basedir="../" default="all">


<!-- Local system paths -->
<property name="servlet.jar" value="C:/dev/jakarta-tomcat-5.0.28/common/lib/servlet-api.jar" />
<property name="distpath.project" value="usergen" />


<!-- Project settings -->
<property name="project.title" value="Content Gate Service " />
<property name="project.distname" value="usergen" />
<property name="project.version" value="1.0" />


<!-- Path settings -->
<property name="doc.path" value="./doc/api" />
<property name="doc.src" value="./src/*" />



<!-- classpath for Struts 1.3 -->
<path id="compile.classpath">
<pathelement path="lib/commons-beanutils.jar" />
<pathelement path="lib/commons-digester.jar" />
<pathelement path="lib/struts.jar" />
<pathelement path="lib/hibernate3.jar" />
<pathelement path="lib/struts-taglib-1.3.5.jar" />
<pathelement path="lib/struts-core-1.3.5.jar" />
<pathelement path="lib/*" />
<pathelement path="${servlet.jar}" />
<pathelement path="classes" />
<pathelement path="${classpath}" />
</path>


<!-- Check timestamp on files -->
<target name="prepare">
<tstamp />
</target>


<!-- Copy any resource or configuration files -->
<target name="resources">
<copy todir="classes" includeEmptyDirs="no">
<fileset dir="src/java">
<patternset>
<include name="**/*.conf" />
<include name="**/*.properties" />
<include name="**/*.xml" />
</patternset>
</fileset>
<fileset dir="src/com">
<patternset>
<include name="**/*.conf" />
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*.hbm.xml" />
</patternset>
</fileset>
</copy>
</target>


<!-- Normal build of application -->
<target name="compile" depends="prepare,resources">
<javac srcdir="src/com" destdir="classes">
<classpath refid="compile.classpath" />
</javac>
</target>


<!-- Remove classes directory for clean build -->
<target name="clean" description="Prepare for clean build">
<delete dir="classes" />
<mkdir dir="classes" />
</target>

<!-- Build entire project -->
<target name="project" depends="clean,prepare,compile" />


<!-- Create binary distribution -->
<target name="dist" description="Create binary distribution">

<mkdir dir="${distpath.project}" />
<jar jarfile="${distpath.project}/${project.distname}.jar" basedir="./classes" />
<copy file="${distpath.project}/${project.distname}.jar" todir="${distpath.project}" />

<war basedir="../" warfile="../../${project.distname}.war" webxml="web.xml">
<exclude name="**/${distpath.project}/**" />
</war>
<move file="../../${project.distname}.war" tofile="${distpath.project}/${project.distname}.war" />

</target>


<!-- Build project and create distribution-->
<target name="all" depends="project,dist" />

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 12:29 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
when you try to run that web-app is that file under $apphome/WEB-INF/classes/com/qpm/usergen/Item.hbm.xml

that's probably where it's looking unless you have an odd classpath.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 12:31 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
when you try to run that web-app is that file under $apphome/WEB-INF/classes/com/qpm/usergen/Item.hbm.xml

that's probably where it's looking unless you have an odd classpath.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 1:00 pm 
Newbie

Joined: Wed Jan 10, 2007 5:36 pm
Posts: 3
kochcp wrote:
when you try to run that web-app is that file under $apphome/WEB-INF/classes/com/qpm/usergen/Item.hbm.xml

that's probably where it's looking unless you have an odd classpath.


hmmmn...its not there!!

that means my build.xml didnt move it there?


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.