This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Mapping exception - cannot find Message.hbm.xml

 
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
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic