-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate and OSGi integration, it unable to load hibernate
PostPosted: Mon Oct 14, 2013 6:46 am 
Newbie

Joined: Mon Oct 14, 2013 6:10 am
Posts: 3
Hi,

I'm creating OSGi dynamic bundle which should communicate with database and I am using Hibernate as I used it in non OSGI application.

I putted original hibernate jars in the OSGi project's lib dir, and make sure those jars are on the project's build path and runtime class-path, I copied all configuration files(i. e. hibernate-cfg.xml) in the root of the OSGi bundled jar. When I execute my bundle (JAR) inside OSGi container it throws error for not finding hibernate-cfg.xml file.

Maybe somebody knows good example how to do that?

At the moment I'm getting following error

2013-10-14 14:56:10 ERROR HibernateUtil:41 - SessionFactory creation failed:org.hibernate.HibernateException: /hibernate.cfg.xml not found


Top
 Profile  
 
 Post subject: Re: Hibernate and OSGi integration, it unable to load hibernate
PostPosted: Tue Oct 15, 2013 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
"I am using Hibernate as I used it in non OSGI application."

If I'm understanding you correctly, do you mean you're not using hibernate-osgi? hibernate-core and hibernate-entitymanager aren't expected to work as-is in an OSGi environment without hibernate-osgi. There are many ClassLoader issues, which you're probably hitting.


Top
 Profile  
 
 Post subject: Re: Hibernate and OSGi integration, it unable to load hibernate
PostPosted: Wed Oct 16, 2013 12:18 am 
Newbie

Joined: Mon Oct 14, 2013 6:10 am
Posts: 3
Absolutely correct, I am not using hibernate-osgi, hibernate-core and hibernate-entitymanager in my code to connect database. Actually I am trying to convert existing application in to a OSGi bundle and I kept hibernate code as it is, currently I am using hibernate3.jar. Please let me know what changes I have to do to convert it to OSGi enable, if possible share some example code.

In my current code I am creating SessionFactory in the following way and facing error while try to get SessionFactory object as it not able to load hibernae.cfg.xml file

private static SessionFactory sessionFactory;

try {

sessionFactory = new Configuration().configure()
.buildSessionFactory();
} catch (HibernateException he) {
LOGGER.error(LoggingConsts.SESSION_FACTORY_FAILED + he);
throw new ExceptionInInitializerError(he);


Thanks in advance


Top
 Profile  
 
 Post subject: Re: Hibernate and OSGi integration, it unable to load hibernate
PostPosted: Wed Oct 16, 2013 12:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch17.html


Top
 Profile  
 
 Post subject: Re: Hibernate and OSGi integration, it unable to load hibernate
PostPosted: Thu Oct 17, 2013 3:59 am 
Newbie

Joined: Mon Oct 14, 2013 6:10 am
Posts: 3
I resolved my issue myself, I just update hibernate jar version with 3.2.6.ga and it start working.
Thanks everybody for your response.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.