蓝图[Karaf] - Spring Orm - Hibernate - LocalSessionFactoryBean - 未找到Entity Vo对象类

时间:2015-02-18 06:44:33

标签: hibernate apache-karaf spring-orm fusefabric

我使用的是Fuse Fabric 6.1.0-redhat-379。我们将基于spring的应用程序迁移到blueprint osgi应用程序。以前我们使用带有hibernate的spring orm来访问db。 我试图将spring orm(service mix bundle)移植到blueprint容器中。现在我面临错误,在hibernate-core bundle中找不到映射资源文件中存在的实体对象。但是我的应用程序包中也存在相同的内容。

<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 | Unable to start blueprint container for bundle common
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean sessionFactoryBean
        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_75]
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:676)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:374)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:270)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:233)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[11:org.apache.aries.util:1.0.1.redhat-610379]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[11:org.apache.aries.util:1.0.1.redhat-610379]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[11:org.apache.aries.util:1.0.1.redhat-610379]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[11:org.apache.aries.util:1.0.1.redhat-610379]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[11:org.apache.aries.util:1.0.1.redhat-610379]
        at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4650)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.Felix$4.run(Felix.java:2123)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.Felix.runInContext(Felix.java:2147)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2121)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]
        at io.fabric8.agent.DeploymentAgent.install(DeploymentAgent.java:743)[60:io.fabric8.fabric-agent:1.0.0.redhat-379]
        at io.fabric8.agent.DeploymentAgent.doUpdate(DeploymentAgent.java:525)[60:io.fabric8.fabric-agent:1.0.0.redhat-379]
        at io.fabric8.agent.DeploymentAgent$2.run(DeploymentAgent.java:252)[60:io.fabric8.fabric-agent:1.0.0.redhat-379]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_75]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_75]
        at java.lang.Thread.run(Thread.java:745)[:1.7.0_75]
Caused by: org.hibernate.MappingException: entity class not found: com.common.reference.vo.ReferenceVO
        at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:138)
        at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:497)
        at org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:87)
        at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:163)
        at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:520)
        at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:148)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.7.0_75]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_75]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_75]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_75]
        at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)
        at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)
        at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:401)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
        at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:252)
        at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:377)
        at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:362)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_75]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_75]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_75]
        at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_75]
        at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]
        ... 34 more
Caused by: java.lang.ClassNotFoundException: com.common.reference.vo.ReferenceVO not found by org.hibernate.core [1161]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_75]
        at java.lang.Class.forName0(Native Method)[:1.7.0_75]
        at java.lang.Class.forName(Class.java:191)[:1.7.0_75]
        at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:193)
        at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:133)
        ... 58 more
2015-02-17 18:11:52,704 | INFO  | agent-1-thread-1 | DeploymentAgent                  | io.fabric8.agent.DeploymentAgent  741 | 60 - io.fabric8.fabric-agent - 1.0.0.redhat-379 |   org.hibernate.osgi / 4.3.6.Final
2015-02-17 18:11:52,713 | INFO  | agent-1-thread-1 | DeploymentAgent                  | io.fabric8.agent.DeploymentAgent  753 | 60 - io.fabric8.fabric-agent - 1.0.0.redhat-379 | Done.

2 个答案:

答案 0 :(得分:0)

我和Karaf有同样的问题。到目前为止我找到的唯一解决方案是在hibernate bundle级别设置dynamic-import。 不确定这是最好的解决方案

答案 1 :(得分:0)

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