aspose file tools*
The moose likes Object Relational Mapping and the fly likes Error reading resource Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Error reading resource Hibernate" Watch "Error reading resource Hibernate" New topic
Author

Error reading resource Hibernate

Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I'm using Hibernate....
my xml file

===== MaterialDTO.hbm.xml =======
<?xml version='1.0' encoding='utf-8'?>

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

<hibernate-mapping>
<class name="factory.material.MaterialDTO" table="material" >
<id name="matid" column="MATID" type="java.lang.Long" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="matname" column="MATNUM" type="java.lang.String" />
<property name="mattype" column="MATTYPE" type="java.lang.String" />
<property name="matname" column="MATNAME" type="java.lang.String" />
<property name="matprovider" column="MATPROVIDER" type="java.lang.String" />
<property name="matunit" column="MATUNIT" type="java.lang.String" />
<property name="matcost" column="MATCOST" type="java.lang.String" />
<property name="isdelete" column="ISDELETE" type="java.lang.String" />
</class>
</hibernate-mapping>


====== hibernate.cfg.xml =====
<?xml version='1.0' encoding='utf-8'?>

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

<hibernate-configuration>

<session-factory>

<property name="connection.datasource">java:comp/env/jdbc/DBConn</property>

<property name="show_sql">true</property>

<property name="use_outer_join">true</property>

<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- Mapping files -->
<mapping resource="factory/material/MaterialDTO.hbm.xml"/>

</session-factory>

</hibernate-configuration>




but when i want to add an object into database...
i saw the exception

javax.servlet.ServletException: net.sf.hibernate.MappingException: Error reading resource: factory/material/MaterialDTO.hbm.xml

any ideas?
thanks...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its probably a classpath issue with MaterialDTO.hbm.xml. Make sure its where it is supposed to be in you app's directory structure (check the Hibernate docs if you are not sure). Your mapping file look fine - its valid xml and superficially anyway looks plausible. You probably want to check your column names and data types though.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I think my classpath is OK.
Maybe the problem is from data type.
I would check it if it's correct.
Thanks.
Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I've found the error.
The declaration of MaterialDTO.hbm.xml is WRONG.
Because I pasted it from hibernate.cfg.xml.

Anyway, thanks a lot.
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
This config may wrong ...

<mapping resource="factory/material/MaterialDTO.hbm.xml"/>

.....

I have some question to tell you ...

Which the server type for use in your project/work ?


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Grady Jamyson
Ranch Hand

Joined: Aug 04, 2002
Posts: 42
I use Tomcat 5.0.24.
burt will
Greenhorn

Joined: Aug 02, 2005
Posts: 2
hello, i am having the same problem and would like to know how you fixed it. i do not understand what you mean when you say

"...The declaration of MaterialDTO.hbm.xml is WRONG.
Because I pasted it from hibernate.cfg.xml.
...."


can you please elaborate...thank you.
 
Don't get me started about those stupid light bulbs.
 
subject: Error reading resource Hibernate