Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Problem with Hibernate and org.springframework.orm-3.0.5.RELEASE (Class not found org.hibernate.cfg.Configuration)
Problem with Hibernate and org.springframework.orm-3.0.5.RELEASE [message #757285] Thu, 17 November 2011 13:28 Go to next message
TorTukiTu Mising name is currently offline TorTukiTu Mising nameFriend
Messages: 12
Registered: August 2011
Junior Member
Hi all,

I am trying to use Hibernate and Virgo. But I am facing a strange ClassNotFound Exception :

[2011-11-17 17:22:23.612] start-signalling-1           <DE0006E> Start failed for bundle 'fr.[app].core.MyProfile.consumer' version '0.1.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://144.fwk4098499/META-INF/spring/bundle-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
        at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
        at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
        at org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
        ... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:189)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        ... 20 common frames omitted
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.hibernate.cfg.Configuration in KernelBundleClassLoader: [bundle=org.springframework.orm_3.0.5.RELEASE]
        at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:138)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 26 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
        at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:134)
        ... 27 common frames omitted



Please, view the messages #2 and #3 in this thread for the details => http://forum.springsource.org/showthread.php?112754-Hibenate-OSGi-Problem-with-org.hibernate.cfg&p=388293#post388293

I spent all my day trying to solve that problem. Any help will be appreciated.

Thank you !
Re: Problem with Hibernate and org.springframework.orm-3.0.5.RELEASE [message #757293 is a reply to message #757285] Thu, 17 November 2011 14:40 Go to previous messageGo to next message
Borislav Kapukaranov is currently offline Borislav KapukaranovFriend
Messages: 80
Registered: September 2010
Member
Hi,

Have you checked Virgo's documentation. We have a section that covers working with Hibernate that gives a hint to add hibernate to your application's scope so that even bundles in it without reference to hibernate can load it.
http://www.eclipse.org/virgo/documentation/virgo-documentation-3.0.0.x/docs/virgo-programmer-guide/htmlsingle/virgo-programmer-guide.html#common-libraries-hibernate

HTH,
Borislav

[Updated on: Thu, 17 November 2011 14:40]

Report message to a moderator

Re: Problem with Hibernate and org.springframework.orm-3.0.5.RELEASE [message #757378 is a reply to message #757293] Fri, 18 November 2011 04:41 Go to previous messageGo to next message
TorTukiTu Mising name is currently offline TorTukiTu Mising nameFriend
Messages: 12
Registered: August 2011
Junior Member
Thank you for answering, Borislav Kapukaranov. Razz

I already read it.

The problem seems to be one of the /reposiroty/ext (org.springframework.orm.hibernate3.LocalSessionFactoryBean) does not to import the org.hibernate.cfg package (But it currently do ! See my following post)

Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.hibernate.cfg.Configuration in KernelBundleClassLoader: [bundle=org.springframework.orm_3.0.5.RELEASE]


I can't make a par file with /ext bundles. So the import-scope:=application instruction will be useless in that case.

An other strange thing, sometimes I don't got the upper line, but the exception "stops" at :

Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:189)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        ... 20 common frames omitted


Is this exception really caused by the org.springframework.orm which try to use hibernate ?

An other guy answered me on the Spring forum :

Quote:

Maybe have a look in the virgo OSGi management interface whether
- the hibernate bundle is installed and active/started
- the hibernate bundle exports the package org.hibernate.cfg (check the version)
- the org.springframework.orm bundle imports the same version


- the hibernate bundle is installed and active/started => Yes
[com.springsource.org.hibernate: 3.3.2.GA => ACTIVE ]
- the hibernate bundle exports the package org.hibernate.cfg (check the version) => Yes
[org.hibernate.cfg 3.3.2.GA => Importing in my MANIFEST.MF org.hibernate.cfg without version specification]
- the org.springframework.orm bundle imports the same version => Yes
[org.hibernate.cfg; version="[3.2.0,4.0.0)"<unwired><optional>]

According to the class documentation at http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/LocalSessionFactoryBean.html,

org.springframework.orm.hibernate3.AbstractSessionFactoryBean Has the following method :

protected  SessionFactory 	newSessionFactory(Configuration config) 


With Configuration = org.hibernate.cfg.Configuration

I suppose I did something wrong and the wrong classloader is used for some reason...

A little hint please ?

Thank you ! =)

[Updated on: Fri, 18 November 2011 05:44]

Report message to a moderator

Re: Problem with Hibernate and org.springframework.orm-3.0.5.RELEASE [message #757379 is a reply to message #757378] Fri, 18 November 2011 05:24 Go to previous messageGo to next message
TorTukiTu Mising name is currently offline TorTukiTu Mising nameFriend
Messages: 12
Registered: August 2011
Junior Member
Here is another hint.

I activated User space console to see exactly what happends:

osgi>ss
...
86 ACTIVE org.springframework.orm_3.0.5.RELEASE
...
143 ACTIVE com.springsource.org.hibernate_3.3.2.GA

osgi>bundle 143
com.springsource.org.hibernate_3.3.2.GA [143]
Id=143, Status=ACTIVE Data Root=...\143\data
"No registered services."
No services in use.
Exported packages
...
org.hibernate.cfg; version="3.3.2.GA"[exported]
...
No fragment bundles
Named class space
com.springsource.org.hibernate; bundle-version="3.3.2.GA"[provided]
No required bundles

osgi>install file://..../MyProfile.consumer-0.1.jar
Bundle ID: 144

osgi> ss
"Framework is launched."
...
144 INSTALLED [my_app].MyProfile.consumer_0.1.0

osgi> bundle 144
[my_app].MyProfile.consumer_0.1.0 [144]
Id=144, Status=INSTALLED Data Root=...\144\data
"No registered services."
No services in use.
No exported packages
No imported packages
No fragment bundles
No named class spaces
No required bundles

osgi> start 144

osgi> ss
...
143 ACTIVE com.springsource.org.hibernate_3.3.2.GA
145 ACTIVE [my_app].MyProfile.consumer_0.1.0

osgi> bundle 144
...
Imported packages
...
org.hibernate.cfg; version="3.3.2.GA"<com.springsource.org.hibernate_3.3.2.GA [143]>
...

osgi> bundle 86
org.springframework.orm_3.0.5.RELEASE [86]
....
org.hibernate.cfg; version="[3.2.0,4.0.0)"<unwired><optional>
....



But I still have the exception in the logs :

[2011-11-18 09:19:26.723] ERROR region-dm-10                 System.err                                                        Exception in thread "region-dm-10" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://145.fwk4098499/META-INF/spring/bundle-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration 
....
[2011-11-18 09:19:26.726] ERROR region-dm-10                 System.err                                                        Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.hibernate.cfg.Configuration in KernelBundleClassLoader: [bundle=org.springframework.orm_3.0.5.RELEASE] 
....


To conclude, the problem happends because of org.springframework.orm does not import org.hibernate.cfg.Configuration but it currently do !

So, I am absolutly lost.... Sad

[Updated on: Fri, 18 November 2011 06:14]

Report message to a moderator

Re: Problem with Hibernate and org.springframework.orm-3.0.5.RELEASE [message #757385 is a reply to message #757379] Fri, 18 November 2011 07:24 Go to previous message
TorTukiTu Mising name is currently offline TorTukiTu Mising nameFriend
Messages: 12
Registered: August 2011
Junior Member
Everything was Ok after a startup -clean...

Some ghost in the machine....
Previous Topic:Working with Maven snapshots
Next Topic:Issue with a servlet that uses RSA code
Goto Forum:
  


Current Time: Tue Apr 23 17:14:02 GMT 2024

Powered by FUDForum. Page generated in 0.04348 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top