Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping exception - cannot find Message.hbm.xml

 
Venkatraman Kandaswamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am studying Hibernate in action and am stuck like a truck in a muck !!

My set up :

Tomcat 5.5.9
Mysql 4.1.12
Struts 1.2

I have a Message.java bean with 3 fields.
This is being mapped to the mysql table in Message.hbm.xml
There is an action class HibernateTest which tries to insert a record into the database.

All the above 3 class files are in the same directory.

Also I have hibernate.properties in WEB-INF/src/java which has the database details in it.

this is the code in HibernateTest.java


Now when I pull this on a browser it fails in the configuration line - where it tries to get the resource.

This is the exception that I get :
net.sf.hibernate.MappingException: Resource: net/kvrlogs/antiPC/actions/Message.hbm.xml not found

What do I do?

Thanks for your help.
 
Venkatraman Kandaswamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
stupid me. The message was loud and clear but not once did I check in WEB-INF/classes to see if message.hbm.xml was there. While building, my hbm.xml was not copied from WEB-INF/src to WEB-INF/classes. So I manually copied the file and that error went off. Then the next error I had was datasource not found. I had to then follow the instructions in the quickstart tutorial to get that working - some issue with JNDI and tomcat - there is a workaround suggested in this tutorial - clicky.

Now I am seeing this exception -


This comes when I am trying to start a transaction. Might be because I am using MySQL 4.1?? Had to do some more ing. Any suggestions on this??

The journey is the reward
 
Venkatraman Kandaswamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well just to update - to help anyone looking at this post - I dropped tomcat and switched to jboss. It also had its share of oddities but finally got it working. Was able to successfully insert a record into the database. I will list the steps that I followed.

1. copy my-sql.ds.xml from JBOSS_HOME/doc/examples/JSA to $JBOSS_HOME/server/default/deploy
2. Edit my-sql.ds.xml to look like this

3. Edit JBOSS_HOME/server/default/conf/standardjaws.xml

4. Edit JBOSS_HOME/server/default/conf/standardjbosscmp-jdbc.xml

5. This is my hibernate.cfg.xml
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic