Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Data not persisting, when it is sent through service layer

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear dudes,
I'm having a simple struts application which has a form to get username and password from the user and call the action class, which persist the data in MYSQL database
Actually in my actin class only i'm persisting the database by calling the service class, which reads the hibernate configuration file(hibernate-cfg.xml) and its mapping file
Actually, i'm getting my data and setting my data in my DAO object( i.e. logindata object in my application)
I'm having problem in persisting that DAO object into database.
My service layer is not able to read my DAO hibernate configuration from hibernate-cfg.xml

The exception i'm getting is:



My application structure:



My hibernate-cfg.xml:


Logindata.hbm.xml:


I've configured my workspace to tomcat by setting a configuration file in conf\cataline\localhost folder of Tomcat5.5

This is my action servlet:loginAction .java


My service classes:
loginservice.java


connectionfactory.java:

Here data entered by the user is getting till the action class and data is getting saved in logindata object i.e. my dao object, for which i'm sure as i generate messages which i get in my console ,but when this object is sent into service layer it is throwing mapping exception

Once again the the exception it is throwing is :


Is my application structure is right and what could be done to fix this?

Awaiting for the response!

regards.
 
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
Your mapping file appears to belong to the package com.srit.login, but it looks like you've put it at the root of the classes directory. Hibernate just looks up resources in the same way Java looks up any resource, so it needs to be in WEB-INF/classes/com/srit/login/ to be found.
 
mara thamizhan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even after putting my Logindata.hbm.xml in WEB-INF/classes/com/srit/login/Logindata.xml
my hibernate configuration file hibernate.cfg.xml is not able to read the corresponding mapping file Logindata.hbm.xml

The exception trace is:


Could any one fix it.
My hibernate.cfg.xml is inside WEB-INF\classes folder.
Logindata.hbm.xml is inside WEB-INF\classes\com\srit\login folder.
Regards.
 
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Namma,

In your hibernate config file, you indicate you've listed the mapping file location as:



As Paul was saying, this tells hibnerate to try to find it in the root directory. Since you have it in the same directory as the class file, you need to update the resource's path:


[ April 11, 2008: Message edited by: Stevi Deter ]
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic