Blueprint〔Karaf〕-Spring Orm-Hibernate-LocalSessionFactoryBea



我使用的是Fuse Fabric 6.1.0-redhat-379。我们将基于spring的应用程序迁移到blueprint osgi应用程序。以前我们使用spring-orm和hibernate来访问数据库。我尝试将spring-orm(服务组合包)移植到蓝图容器。现在我面临的错误是,在hibernate核心捆绑包中找不到映射资源文件中存在的实体对象。但在我的应用程序包中也是如此。

<bean id="sessionFactoryBean"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
activation="eager" init-method="afterPropertiesSet">
<property name="dataSource" ref="dataSourceRef" />
<property name="mappingLocations">
<list>
<bean class="com.base.support.io.BundleResource">
<argument index="0" type="java.lang.String" value="com/reference/vo/hbm/Reference.hbm.xml" />
<argument index="1" type="org.osgi.framework.BundleContext" ref="blueprintBundleContext"/>
</bean>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">${showSql}</prop>
<prop key="hibernate.dialect">${dialect}</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
<prop key="hibernate.generate_statistics">false</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>             
</props>
</property>
</bean>
t.core-1.0.1.redhat-610379|无法启动bundle common的蓝图容器org.osgi.service.blueprint.cotainer.ComponentDefinitionException:无法初始化bean会话FactoryBean位于org.apache.aries.bluent.contacter.Beancipe.runBeanProcUnit(Beancipe.java:714)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]网址:org.apache.aries.bluent.contacter.Beancipe.internalCreate2(Beancipe.java:824)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]网址:org.apache.aries.bluent.contacter.Beancipe.internalCreate(Beancipe.java:787)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]在org.apache.aries.bluent.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]在java.util.concurrent.FFutureTask.run(FutureTask.java:262)[:1.7.0_75]网址:org.apache.aries.bluent.di.AbstractRecipe.create(AbstractRecipe.java:88)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]网址:org.apache.aries.bluendat.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[9:org.apache.airs.bluendap.core:1.0.1.redhat-610379]网址:org.apache.aries.bluendat.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[9:org.apache.airs.bluendap.core:1.0.1.redhat-610379]网址:org.apache.aries.bluendat.container.BlueprintContainerImpl.instantiateEagleComponents(BlueprintContainerImpl.java:676)[9:org.apache.airs.bluendap.core:1.0.1.redhat-610379]网址:org.apache.aries.bluendat.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:374)[9:org.apache.airs.bluendap.core:1.0.1.redhat-610379]在org.apache.aries.bluendat.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[9:org.apache.airs.bluendap.core:1.0.1.redhat-610379]网址:org.apache.aries.bluendat.container.BlueprintExtender.createContainer(BlueprintExtender.java:270)[9:org.apache.airs.bluendar.core:1.0.1.redhat-610379]网址:org.apache.aries.bluendat.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:233)[9:org.apache.airs.bluendar.core:1.0.1.redhat-610379]在org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundle tracker.java:500)[11:org.apache.airs.util:1.0.1.redhat-610379]在org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundle tracker.java:433)[11:org.apache.airs.util:1.0.1.redhat-610379]在org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundle tracker.java:725)[11:org.apache.airs.util:1.0.1.redhat-610379]在org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundle tracker.java:463)[11:org.apache.airs.util:1.0.1.redhat-610379]在org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundle tracker.java:422)[11:org.apache.airs.util:1.0.1.redhat-610379]网址:org.apache.filex.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.fielix.framework-4.0.3.redhat-610379.jar:]在org.apache.filix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.filex.framework-4.0.3.redhat-610379.jar:]在org.apache.filix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.filex.framework-4.0.3.redhat-610379.jar:]在org.apache.filex.framework.Fix.fireBundleEvent(felix.java:4650)[org.apache.fielix.framework-4.0.3.redhat-610379.jar:]在org.apache.filex.framework.Filex$4.run(felix.java:2123)[org.apache.fielix.framework-4.0.3.redhat-610379.jar:]在org.apache.filex.framework.Filex.runInContext(felix.java:2147)[org.apache.fielix.framework-4.0.3.redhat-610379.jar:]在org.apache.filex.framework.Filex.startBundle(felix.java:2121)[org.apache.fielix.framework-4.0.3.redhat-610379.jar:]在org.apache.filix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.filex.framework-4.0.3.redhat-610379.jar:]在org.apache.filix.framework.BundleImpl.start(BundleImpl.java:942)[org.apache.filex.framework-4.0.3.redhat-610379.jar:]位于io.fabric8.agent.DeploymentAgent.install(DeploymentAgent.java:743)[60:io.fabrick8.fabric-agent:1.0.0.redhat-379]位于io.fabric8.agent.DeploymentAgent.doUpdate(DeploymentAgent.java:525)[60:io.fabrick8.fabric-agent:1.0.0.redhat-379]位于io.fabric8.agent.DeploymentAgent$2.run(DeploymentAgent.java:252)[60:io.fabrick8.fabric-agent:1.0.0.redhat-379]在java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_75]在java.util.concurrent.FFutureTask.run(FutureTask.java:262)[:1.7.0_75]位于java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1145)[:1.7.0_75]位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_75]在java.lang.Thread.run(Thread.java:745)[:1.7.0_75]由:org.hubinate.MappingException引起:找不到实体类:com.common.reference.vo.ReferenceVO位于org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:138)位于org.hibernate.ttuple.PropertyFactory.getGetter(PropertyFactory.java:497)位于org.hibernate.ttuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:87)位于org.hibernate.ttup.entity.EntityMetamodel.(EntityMetamodel.java:163)位于org.hibernate。persister.entity.AbstractEntityPersister.(AbstractEntityPersester.java:520)位于org.hibernate。persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:148)在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)[:1.7.0_75]在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessor Impl.java:57)[:1.7.0_75]在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessor Impl.java:45)[:1.7.0_75]位于java.lang.reflect.Constructure.newInstance(Constructor.java:526)[:1.7.0_75]位于org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)位于org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)位于org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:401)位于org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)位于org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)位于org.springframework.om.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:252)位于org.springframework.om.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:377)位于org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:362)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)[:1.7.0_75]在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_75]在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_75]位于java.lang.reflect.Method.ioke(Method.java:606)[:1.7.0_75]在org.apache.aries.bluent.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]在org.apache.aries.bluent.contacter.Beancipe.invoke(Beancipe.java:958)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]位于org.apache.aries.bluent.contacter.Beancipe.runBeanProcUnit(Beancipe.java:712)[9:org.apache.airs.bluent.core:1.0.1.redhat-610379]…更多34引起原因:java.lang.ClassNotFoundException:com.common.reference.vo.ReferenceVO未被org.hibernate.core[1161]找到网址:org.apache.filex.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)网址:org.apache.filex.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)网址:org.apache.filex.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:11955)在java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_75]位于java.lang.Class.forName0(本机方法)[:1.7.0_75]在java.lang.Class.forName(Class.java:191)[:1.7.0_75]位于org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:193)位于org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:133)…还有582015-02-17 18:11:52704|信息|agent-1-thread-1|DeploymentAgent|io.fabric8.agent.DeploymentAgent 741|60-io.fabrick8.fabric-agent-1.0.0.redhat-379|org.hibernate.osgi/4.3.6.最终2015-02-17 18:11:52713|信息|agent-1-thread-1|部署代理|io.fabric8.agent.DeploymentAgent 753|60-io.fabrick8.fabric-agent-1.0.0.redhat-379|完成

我对Karaf也有同样的问题。到目前为止,我找到的唯一解决方案是在hibernate bundle级别设置动态导入。不确定这是的最佳解决方案

这适用于Fuse 6.2,根据所选的hibernate版本提供正确的JPA版本。

相关内容

  • 没有找到相关文章

最新更新