- This topic has 5 replies, 5 voices, and was last updated 19 years, 11 months ago by sakouha.
-
AuthorPosts
-
victor.lewisMemberI added the Hibernate capability to an existing EJB project and created a simple class mapped to one table.
In the currentSession() method of the Session class generated by MyEclipseIDE it passes the path to the hibernate.cfg.xml like this:
cfg.configure(CONFIG_FILE_LOCATION); sessionFactory = cfg.buildSessionFactory();
Hibernate then complains that it cannot find the hibernate.cfg.xml file. I guessed that this is a class-loader problem because Hibernate’s jars are in the JBoss server’s lib directory (server/default/lib) and it cannot see the hibernate.cfg.xml file is in the EJB’s jar file.
I confirmed that this is the case my modifying the code in currentSession() to call Class.getResource() from a class loaded by the EJB’s class loader and passing the URL to Configuration.configure(URL) rather than Configuration.configure(String). This worked.
The problem is that when the code from the Hibernate jar reads hibernate.cfg.xml it has a reference to mapping files (e.g. com/blueshoe/fish/hibernate/PClass.hbm.xml) which cannot be found my Hibernate’s class-loader for the same reason that it could not find hibernate.cfg.xml.
What must I do to allow the Hibernate code to find the configuration files in my EJB’s jar?
============Config Info==============
– Was Eclipse freshly installed for MyEclipse?Yes
– Are any other external plugins installed?
No
– How many plugins in the <eclipse>/plugins directory are like org.eclipse.pde.*
8
– What MyEclipse version are you using? (Help > About Eclipse Platform > Features)
3.8.2
– What JDK version are you using to run Eclipse? (java -version)
1.4.2_06
– What JDK version are you using to launch your application server?
1.4.2_06
– What steps did you take that resulted in the issue?
See above
– What application server are you using?
jboss 4.0.0
– Are there any exceptions in the Eclipse log file?(<workspace>/.metadata/.log)
None.
Riyad KallaMemberVictor, I don’t mean to offload you but this really is a Hibernate functionality that I’m not aware of… I would suggest asking how to load mapping files from a JAR in the Hib forums: http://forum.hibernate.org/
victor.lewisMemberI’ll poke around over there but the problems I am having are in code that was generated by MyEclipseIDE (the Session class). I kind of assume that when you developed this feature you had it working and that I had committed a configuration faux pas.
support-michaelKeymasterJBoss has native support for Hibernate. See the following URL for configuration and deployment information:
http://www.jboss.org/wiki/Wiki.jsp?page=JBossHibernate
http://www.hibernate.org/66.htmlFor a non-JBoss environment you need to package your EJB as an EAR and include the Hibernate libraries in the EAR. The upcoming ME 3.8.3 release should greatly simplify this process.
support-jeffMemberThe hibernate tooling and the SessionFactory generated code is geared toward simple webapp development. We did not have EJB in mind as a use case for the SessionFactory stuff. There is nothing the code can do to affect class-loader visiblity. It is an app server config thing.
sakouhaMemberI found same question.
Try it:
you put the Hibernate.cfg.xml to [JBOSS_HOME]\server\default\conf
the new error happened.
sessionFactory :null -
AuthorPosts