Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate with Struts Mapping Exception

 
gunjan bohra
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am try to using hibernate with struts
I have made hibernate.cfg.xml.
In that file I am using <mapping> tag
Which is like
<mapping resource="/WEB-INF/xml/Department.hbm.xml"/>
It's corrosponging Struts-config entry is
<plug-in className="com.exam.util.HibernatePlugin">
<set-property property="path" value="../../../../hibernate.cfg.xml"/>
</plug-in>
When server start it call Hibernateplugin class and in hibernate.cfg.xml file I called Department.hbm.xml file which is not fould by server and its giving following error

ERROR [main] com.exam.util.HibernatePlugin init- mapping error
net.sf.hibernate.MappingException: Resource: /WEB-INF/xml/Department.hbm.xml not
found
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:334
)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:101
3)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969
)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:912)
at com.exam.util.HibernatePlugin.init(Unknown Source)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
t.java:869)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1105)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:93
2)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3915)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
176)


Please solve this issue I am stuck with this problem
Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ERROR [main] com.exam.util.HibernatePlugin init- mapping error
net.sf.hibernate.MappingException: Resource: /WEB-INF/xml/Department.hbm.xml not
found

According to the error message the mapping file Department.hbm.xml is not in the directory /WEB-INF/xml/ of your web app. However, your mapping looks wrong. WEB-INF is the root of your classpath for the web app, so I don't think you need to include it in your mapping path. Try /xml/Department.hbm.xml instead.
 
gunjan bohra
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Actually HibernatePlugin class is in com.exam.util package in classes folder of WEB-INF dir.
I have given path ../xml/hibernate.cfg.xml.
Now it's working file .
But logically I feel that is not right way !!
Is it So!!!
If yes how can it possible .
Because upto web-inf dir it's default path
IT's not working when I gives /xml/Hibernate.cfg.xml.
Thanks for your reply
With Best
 
gunjan bohra
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Actually HibernatePlugin class is in com.exam.util package in classes folder of WEB-INF dir.
I have given path ../xml/hibernate.cfg.xml.
Now it's working file .
But logically I feel that is not right way !!
Is it So!!!
If yes how can it possible .
Because upto web-inf dir it's default path
IT's not working when I gives /xml/Hibernate.cfg.xml.
Thanks for your reply
With Best
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic