I'm trying to use Hibernate within Karaf. I've managed to get it to work if
I deploy Hibernate and its dependencies by dropping the jar's in the deploy
folder. However, I cannot get it to work using Karaf features (which I would
like to). I get the following exception:
*2011-05-09 22:23:23,069 | ERROR | ExtenderThread-2 | ContextLoaderListener
> | BundleApplicationContextListener 50 | Application context
> refresh failed (OsgiBundleXmlApplicationContext(bundle=tra,
> config=osgibundle:/META-INF/spring/*.xml))
> **org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name
> 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0':
> Invocation of init method failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'tra_traService' defined in URL
> [bundle://136.0:0/META-INF/spring/context.xml]: Cannot resolve reference to
> bean 'tra_transactionDAO' while setting bean property 'transactionDAO';
> nested exception is org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'tra_transactionDAO' defined in URL
> [bundle://136.0:0/META-INF/spring/context.xml]: Instantiation of bean
> failed; nested exception is java.lang.NoClassDefFoundError:
> org/hibernate/criterion/Criterion
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)[83:org.springframework.context:3.0.5.RELEASE]
> ** at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[92:org.springframework.osgi.core:1.2.1]
> ** at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[92:org.springframework.osgi.core:1.2.1]
> ** at
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[92:org.springframework.osgi.core:1.2.1]
> ** at
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[92:org.springframework.osgi.core:1.2.1]
> ** at
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[93:org.springframework.osgi.extender:1.2.1]
> ** at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]
> **Caused by: org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'tra_traService' defined in URL
> [bundle://136.0:0/META-INF/spring/context.xml]: Cannot resolve reference to
> bean 'tra_transactionDAO' while setting bean property 'transactionDAO';
> nested exception is org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'tra_transactionDAO' defined in URL
> [bundle://136.0:0/META-INF/spring/context.xml]: Instantiation of bean
> failed; nested exception is java.lang.NoClassDefFoundError:
> org/hibernate/criterion/Criterion
> ** at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean.afterPropertiesSet(OsgiServiceFactoryBean.java:167)[92:org.springframework.osgi.core:1.2.1]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)[81:org.springframework.beans:3.0.5.RELEASE]
> ** ... 14 more
> **Caused by: org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'tra_transactionDAO' defined in URL
> [bundle://136.0:0/META-INF/spring/context.xml]: Instantiation of bean
> failed; nested exception is java.lang.NoClassDefFoundError:
> org/hibernate/criterion/Criterion
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[81:org.springframework.beans:3.0.5.RELEASE]
> ** at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)[81:org.springframework.beans:3.0.5.RELEASE]
> ** ... 26 more
> **Caused by: java.lang.NoClassDefFoundError:
> org/hibernate/criterion/Criterion
> ** at java.lang.Class.getDeclaredConstructors0(Native Method)[:1.6.0_25]
> ** at
> java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)[:1.6.0_25]
> ** at java.lang.Class.getConstructor0(Class.java:2699)[:1.6.0_25]
> ** at java.lang.Class.getDeclaredConstructor(Class.java:1985)[:1.6.0_25]
> ** at
> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:65)
> ** at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)[81:org.springframework.beans:3.0.5.RELEASE]
> ** ... 34 more
> **Caused by: java.lang.ClassNotFoundException:
> org.hibernate.criterion.Criterion not found by tra [136]
> ** at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
> ** at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
> ** at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
> ** at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_25]
> ** ... 40 more*
I have defined the following feature:
* <feature name="trs-hibernate" version="${project.version}">
> ** <bundle>mvn:org.hibernate/com.springsource.org.hibernate/3.2.6.ga
> </bundle>
> ** <bundle>mvn:org.dom4j/com.springsource.org.dom4j/1.6.1</bundle>
> ** <bundle>mvn:org.jboss.javassist/com.springsource.javassist/3.3.0.ga
> </bundle>
> **
> <bundle>mvn:org.objectweb.asm/com.springsource.org.objectweb.asm/1.5.3</bundle>
> **
> <bundle>mvn:org.objectweb.asm/com.springsource.org.objectweb.asm.attrs/1.5.3</bundle>
> ** <bundle>mvn:org.antlr/com.springsource.antlr/2.7.7</bundle>
> ** <bundle>mvn:aspectj/aspectjweaver/1.6.6.RELEASE</bundle>
> ** <bundle>mvn:aspectj/aspectjruntime/1.6.6.RELEASE</bundle>
> ** </feature>*
I have also tried to change the startlevel of the above bundles (to 50) to
make sure they are started before my bundles (that use Hibernate) is
started. But the start level does not seem to be the problem. Is the problem
that the bundles need to be present when the bundles in startup.properties
are installed? Will bundles deployed using the deploy folder be treated
"equal" to the bundles in startup.properties?
Is there anyway to get this to work using Karaf features?
/Bengt