Bengt, yes those Spring bundles do all kinds of optional imports, that's why you sometimes end up in this inconvenient position where you think you have all that needs to be provided available but still since one of those bundles is already resolved nothing works. That's why I made those extra fragments to switch optional imports into required ones.
For investigation I recommend using package:imports/exports and headers on the Karaf shell for getting detailed informations. regards, Achim 2011/5/10 Bengt Rodehav <[email protected]>: > Thanks for your reply Charles, > Yes, the direct cause is the exception you specify. However, everything > works fine if I include spring-orm as a private package. Thus, there is > nothing wrong with my spring context definition file per se. I'm sure the > problem has to do with classloading/bundle resolving stuff. > Perhaps it's because spring-aop is already installed? Maybe it's not enough > delaying the resolving of spring-orm, perhaps spring-aop must also resolve > after my classes are installed? > I'm using spring-aop to define transaction attributes for my spring beans. > /Bengt > > 2011/5/10 Charles Moulliard <[email protected]> >> >> Hi Bengt, >> >> Your problem is linked to this error (from your stacktrace) >> >> Caused by: java.lang.IllegalStateException: Expecting raw type, not: >> org.springframework.beans.factory.FactoryBean >> at >> org.aspectj.weaver.TypeFactory.createParameterizedType(TypeFactory.java:37)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> Regards, >> >> Charles Moulliard >> >> Sr. Principal Solution Architect - FuseSource >> Apache Committer >> >> Blog : http://cmoulliard.blogspot.com >> Twitter : http://twitter.com/cmoulliard >> Linkedin : http://www.linkedin.com/in/charlesmoulliard >> Skype: cmoulliard >> >> >> >> On Tue, May 10, 2011 at 12:16 PM, Bengt Rodehav <[email protected]> wrote: >> > Achim, >> > You're right that the problem concerns spring-orm. If I specify >> > org.springframework.orm* as a private package (so that it is included in >> > my >> > bundle) and I also specify the following dynamic imports: >> >> >> >> >> >> >> >> org.springframework.aop,org.springframework.aop.*,org.aopalliance.aop,org.hibernate.*,net.sf.cglib.* >> > >> > ...then it works. But I can't seem to find a way to use an already >> > installed >> > spring-orm bundle. So, it sounds like the problem you describe but in my >> > case spring-orm is not installed until I install it as part of my >> > feature, >> > as follows: >> >> >> >> ... >> >> <feature name="trs-persistence" version="${project.version}"> >> >> <feature version="${project.version}">trs-util</feature> >> >> >> >> <bundle>mvn:org.springframework/spring-aop/${spring-version}</bundle> >> >> >> >> <bundle>mvn:org.springframework/spring-jdbc/${spring-version}</bundle> >> >> >> >> <bundle>mvn:org.springframework/spring-orm/${spring-version}</bundle> >> >> >> >> >> >> <bundle>mvn:org.springframework/spring-transaction/${spring-version}</bundle> >> >> <bundle>mvn:joda-time/joda-time/${joda-time-version}</bundle> >> >> >> >> <bundle>mvn:se.digia.trs.persistence/tra/${project.version}</bundle> >> >> </feature> >> >> ... >> > >> > Wouldn't my bundle (the "tra" bundle) be visible when spring-orm >> > resolves? >> > How does this work? Can you explain? >> > From what I've understood, the bundles in startup.properties will see >> > each >> > other at resolve time but they will not see bundles loaded by Karaf >> > features >> > - right? But, what bundles will the features see when they resolve? Will >> > they see other bundles in the same feature? Bundles in other features? >> > Bundles in startup.properties? >> > This is pretty tricky - I think. Ideally, it shouldn't matter whether I >> > provision Karaf using startup.properties or via features - they should >> > all >> > resolve against each other. >> > BTW, the exception I now get is the following: >> >> >> >> 2011-05-10 12:01:01,826 | 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://144.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://144.0:0/META-INF/spring/context.xml]: Cannot resolve >> >> reference to >> >> bean 'tra_sessionFactory' while setting bean property 'sessionFactory'; >> >> nested exception is >> >> org.springframework.beans.factory.BeanCreationException: >> >> Error creating bean with name 'tra_sessionFactory' defined in URL >> >> [bundle://144.0:0/META-INF/spring/context.xml]: Initialization of bean >> >> failed; nested exception is java.lang.IllegalStateException: Expecting >> >> raw >> >> type, not: org.springframework.beans.factory.FactoryBean >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)[89:org.springframework.context:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[98:org.springframework.osgi.core:1.2.1] >> >> at >> >> >> >> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[98:org.springframework.osgi.core:1.2.1] >> >> at >> >> >> >> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[98:org.springframework.osgi.core:1.2.1] >> >> at >> >> >> >> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[98:org.springframework.osgi.core:1.2.1] >> >> at >> >> >> >> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[99: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://144.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://144.0:0/META-INF/spring/context.xml]: Cannot resolve >> >> reference to >> >> bean 'tra_sessionFactory' while setting bean property 'sessionFactory'; >> >> nested exception is >> >> org.springframework.beans.factory.BeanCreationException: >> >> Error creating bean with name 'tra_sessionFactory' defined in URL >> >> [bundle://144.0:0/META-INF/spring/context.xml]: Initialization of bean >> >> failed; nested exception is java.lang.IllegalStateException: Expecting >> >> raw >> >> type, not: org.springframework.beans.factory.FactoryBean >> >> at >> >> >> >> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean.afterPropertiesSet(OsgiServiceFactoryBean.java:167)[98:org.springframework.osgi.core:1.2.1] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)[87: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://144.0:0/META-INF/spring/context.xml]: Cannot resolve >> >> reference to >> >> bean 'tra_sessionFactory' while setting bean property 'sessionFactory'; >> >> nested exception is >> >> org.springframework.beans.factory.BeanCreationException: >> >> Error creating bean with name 'tra_sessionFactory' defined in URL >> >> [bundle://144.0:0/META-INF/spring/context.xml]: Initialization of bean >> >> failed; nested exception is java.lang.IllegalStateException: Expecting >> >> raw >> >> type, not: org.springframework.beans.factory.FactoryBean >> >> at >> >> >> >> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)[87:org.springframework.beans:3.0.5.RELEASE] >> >> ... 26 more >> >> Caused by: org.springframework.beans.factory.BeanCreationException: >> >> Error >> >> creating bean with name 'tra_sessionFactory' defined in URL >> >> [bundle://144.0:0/META-INF/spring/context.xml]: Initialization of bean >> >> failed; nested exception is java.lang.IllegalStateException: Expecting >> >> raw >> >> type, not: org.springframework.beans.factory.FactoryBean >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)[87:org.springframework.beans:3.0.5.RELEASE] >> >> ... 36 more >> >> Caused by: java.lang.IllegalStateException: Expecting raw type, not: >> >> org.springframework.beans.factory.FactoryBean >> >> at >> >> >> >> org.aspectj.weaver.TypeFactory.createParameterizedType(TypeFactory.java:37)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.reflect.JavaLangTypeToResolvedTypeConverter.fromType(JavaLangTypeToResolvedTypeConverter.java:75)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.reflect.JavaLangTypeToResolvedTypeConverter.fromTypes(JavaLangTypeToResolvedTypeConverter.java:123)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getDeclaredInterfaces(Java15ReflectionBasedReferenceTypeDelegate.java:126)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.ReferenceType.getDeclaredInterfaces(ReferenceType.java:594)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.ResolvedType.getDirectSupertypes(ResolvedType.java:66)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:183)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.JoinPointSignatureIterator.hasNext(JoinPointSignatureIterator.java:74)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:291)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:106)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:146)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.internal.tools.PointcutExpressionImpl.getShadowMatch(PointcutExpressionImpl.java:235)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesExecution(PointcutExpressionImpl.java:101)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(PointcutExpressionImpl.java:92)[47:com.springsource.org.aspectj.weaver:1.6.6.RELEASE] >> >> at >> >> >> >> org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:361)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:249)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.support.AopUtils.canApply(AopUtils.java:216)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)[88:org.springframework.aop:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)[87:org.springframework.beans:3.0.5.RELEASE] >> >> at >> >> >> >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[87:org.springframework.beans:3.0.5.RELEASE] >> >> ... 42 more >> > >> > Not sure if it helps. I've tried various combinations of loading the >> > bundles >> > and I get a number of different exceptions. The only thing that seems to >> > work is to not use the already installed spring-orm. >> > /Bengt >> > >> > >> > 2011/5/9 Bengt Rodehav <[email protected]> >> >> >> >> Thanks a lot for your quick reply Achim. I do use the >> >> org.springframework.orm package via spring-hibernate3. However, >> >> currently >> >> those packages are included in my client bundle (as private packages). >> >> Maybe >> >> that's part of my problem. I'll try to do it your way and see if it >> >> helps. >> >> /Bengt >> >> >> >> 2011/5/9 Achim Nierbeck <[email protected]> >> >>> >> >>> Hi Bengt, >> >>> >> >>> from your Stacktrace I can guess you try to use Hibernate with Spring, >> >>> possibly also with spring-orm, right? >> >>> Well since Spring-ORM is probably already started it's not able to >> >>> "see" >> >>> the corresponding Hibernate packages >> >>> since those are imported optionally. To get those optionally packages >> >>> resolved you usually do a refresh on >> >>> the Spring-ORM bundle which is OK during development time but usually >> >>> not >> >>> in Production :-) >> >>> What I have done before to make sure that the Spring-ORM bundle is >> >>> actually importing the provided packages >> >>> from Hibernate, I did create a special Fragment bundle where I just >> >>> added >> >>> a manifest file >> >>> where the required Hibernate Packages where actually Imported without >> >>> the >> >>> optional description. >> >>> This makes sure Spring-ORM is only resolved/started when your >> >>> Hibernate >> >>> bundle is available. >> >>> >> >>> >> >>> Regards, Achim >> >>> >> >>> >> >>> >> >>> Am 09.05.2011 22:26, schrieb Bengt Rodehav: >> >>> >> >>> 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 >> >> >> > >> > > > -- -- *Achim Nierbeck* Apache Karaf <http://karaf.apache.org/> Committer & PMC OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
