• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with hibernate application

 
V Patil
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am getting below given error....
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: areapatch_master.hbm.xml






areapatch_master.java






Abstractareapatch_master.java


[ Edited to use code tags - Paul Sturrock ]
[ October 08, 2008: Message edited by: Paul Sturrock ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is areapatch_master.hbm.xml on your claspath? Is it where its meant to be?

(NB: that's a very old version of Hibernate you appear to be using. Any reason you are not using the latest?)
 
V Patil
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
path is correct.
there is some problem with mapping.please help.
version which we are using is according to the requirement.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

path is correct

Are you sure? There are a few reasons why Hibernate will complain about difficulties handling a mappign file.
  • The mapping file is not valid as per the DTD. In this instance there will be a parsing exeption included in the stacktrace telling you what the issue is.
  • The mapping file contains invalid table/column information. In this instance again there will be more detail in the stacktrace to say what is wrong.
  • The mapping file has not been added to the SessionFactory's configuration.
  • The mapping file is not where the SessionFactory's configuration states it should be.

  • These last two are the only ones I can think of where Hibernate gives no other message than an "error reading resource". I'd check both to make sure.
     
    V Patil
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Error Creating SessionFactory
    net.sf.hibernate.MappingException: Error reading resource: co/in/anant/eqsw/pojo/areapatch_master.hbm.xml
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:340)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
    at co.in.anant.eqsw.utilities.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:45)
    at co.in.anant.eqsw.beans.EQ_NewAreaPatch.getAllStateDetails(EQ_NewAreaPatch.java:64)
    at co.in.anant.eqsw.action.NewAreaPatchAction.executeAction(NewAreaPatchAction.java:93)
    at co.in.anant.eqsw.action.EQ_BaseAction.execute(EQ_BaseAction.java:63)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: net.sf.hibernate.MappingException: persistent class [areapatch_master] not found
    at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:84)
    at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
    at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
    at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:289)
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
    ... 30 more
    Caused by: java.lang.ClassNotFoundException: areapatch_master
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
    at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:81)
    ... 35 more
    Inside processPreprocess of request processor
    Inside base Action
    Error Creating SessionFactory
    net.sf.hibernate.MappingException: Error reading resource: co/in/anant/eqsw/pojo/accstatemaster.hbm.xml
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:340)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
    at co.in.anant.eqsw.utilities.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:45)
    at co.in.anant.eqsw.beans.EQ_NewAreaPatch.getAllStateDetails(EQ_NewAreaPatch.java:64)
    at co.in.anant.eqsw.action.NewAreaPatchAction.executeAction(NewAreaPatchAction.java:93)
    at co.in.anant.eqsw.action.EQ_BaseAction.execute(EQ_BaseAction.java:63)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: net.sf.hibernate.MappingException: duplicate import: accstatemaster
    at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
    at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
    at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
    at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
    at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:289)
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
    ... 30 more
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Caused by: java.lang.ClassNotFoundException: areapatch_master

    There you go. Your class "areapatch_master" is missing from your classpath. Given how you have mapped it, arreapatch_master.class should exist in the default package of your application and so at the root of your classpath.
    [ October 08, 2008: Message edited by: Paul Sturrock ]
     
    V Patil
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    HibernateSessionFactory.java
    --------------------------------------------------------




    hibernate.cfg.xml
    -----------------------------------------------------


    [ Edited to use code tags - Paul Sturrock ]
    [ October 08, 2008: Message edited by: Paul Sturrock ]
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Vikas, please use code tags when posting code. It makes it far easier for people to help you.

    That aside, I'm not sure if there is a question to go with the code you've posted? The source of your issue is still your classpath as described above.
     
    V Patil
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    does that means my hibernate.cfg.xml ,areapatch_master.hbm.xml and pojo files should be in classpath?
     
    V Patil
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    does that means my hibernate.cfg.xml ,areapatch_master.hbm.xml and pojo files should be in classpath? is this a rule?
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Your classes need to be in your classpath - that is true of Java whether or not you are using Hibernate. Typically you would keep your configuration and mapping files in your classpath. You can manually configure these programatically, so its not absolutely necessary, but the easiest thing to do is keep your config and mapping files in your class structure.
     
    V Patil
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hibernate.hbm.xml file is in classpath location.
    and other config i.e. areapatch_master.hbm.xml file is kept in mappings folder,path is specified correctly.
    while creating areapatch_master.hbm.xml and other pojo files they are created in hibernate3.0 and we are using hibernate 2.1
    and previously by making few changes in mapping files it was working but now it is giving error.
    please help.
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    hibernate.hbm.xml file is in classpath location.
    and other config i.e. areapatch_master.hbm.xml file is kept in mappings folder,path is specified correctly.

    OK, but the class that is missing is areapatch_master, which according to your mapping should exist in the default package. Does it?


    while creating areapatch_master.hbm.xml and other pojo files they are created in hibernate3.0 and we are using hibernate 2.1

    Why are you writing mapping files to one version of Hibernate and deploying with an older version? That's just not going to work. The doctype in the mapping file will reference the wrong DTD. Elements in your mapping file man not be supported, and if they are they could include attributes that are not supported. Why not write to and deploy in the same version of Hibernate?


    previously by making few changes in mapping files it was working but now it is giving error.

    Though I am very skeptical that it is a wise thing to do, the problem (according to the stack trace) is not the mapping file, its the classpath.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic