Link to home
Start Free TrialLog in
Avatar of HappyEngineer
HappyEngineer

asked on

hibernate resource not found when run inside eclipse

I use Hibernate 3 in Eclipse with Hibernate Synchronizer. When I run code that uses hibernate from the command line (executed using ant) it also works fine. However, if I run that same app in eclipse it fails with the error message at the end of this question.

The problem is that when run from inside eclipse "Thread.currentThread().getContextClassLoader().getResourceAsStream( path )" returns null whereas it succeeds when run outside of eclipse.

What should I do to get this to run inside eclipse?


ERROR[2006-04-04 22:15:27,545] com.knowlist.search.IndexUpdaterQueueManager.main(IndexUpdaterQueueManager.java:39)(IndexUpdaterQueueManager.java39):
java.lang.RuntimeException: org.hibernate.MappingException: Resource: /com/knowlist/list/hh/CustomObjAffinity.hbm not found
      at com.knowlist.list.hh.HibernateInit.doInit(HibernateInit.java:66)
      at com.knowlist.list.hh.HibernateInit.doInit(HibernateInit.java:25)
      at com.knowlist.search.IndexUpdaterQueueManager.main(IndexUpdaterQueueManager.java:29)
Caused by: org.hibernate.MappingException: Resource: /com/knowlist/list/hh/CustomObjAffinity.hbm not found
      at org.hibernate.cfg.Configuration.addResource(Configuration.java:444)
      at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1313)
      at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1285)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1267)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1234)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1162)
      at com.knowlist.list.hh.base._BaseRootDAO.initialize(_BaseRootDAO.java:57)
      at com.knowlist.list.hh.base._BaseRootDAO.initialize(_BaseRootDAO.java:41)
      at com.knowlist.list.hh.HibernateInit.doInit(HibernateInit.java:35)
      ... 2 more
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HappyEngineer
HappyEngineer

ASKER

I found that if I run it using ant from either the command line or from inside eclipse then it executes fine. However, if I execute it directly in eclipse then it fails in the way described above.

I opened up the run configuration in eclipse for this app and set the classpath up to be just like that in the build file and it didn't make any difference.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's at:
  J:\prog\workspace\KnowList\WebRoot\WEB-INF\classes

The ant target (which works):
      <target name="indexUpdater">
            <java classname="com.knowlist.search.IndexUpdaterQueueManager">
                  <classpath>
                        <pathelement location="WebRoot/WEB-INF/classes"/>
                        <fileset dir="WebRoot/WEB-INF/lib">
                              <include name="*.jar"/>
                        </fileset>
                  </classpath>
            </java>
      </target>

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found that the problem went away when I removed the preceding slash from the beginning of the hbm. So, instead of "/com/knowlist/list/hh/CustomObjAffinity.hbm" I use "com/knowlist/list/hh/CustomObjAffinity.hbm".