• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Error reading resource Hibernate

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Tomcat 5.0.24.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic