当前位置: 首页 > 知识库问答 >
问题:

Blueprint[Karaf]-Spring Orm-Hibernate-LocalSessionFactoryBean-找不到实体Vo对象类

钦侯林
2023-03-14

我正在使用保险丝织物6.1.0-红帽-379。我们将基于Spring的应用程序迁移到蓝图osgi应用程序。以前我们使用的是带有hibernate的Spring orm来访问数据库。我试图将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 | 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个答案

扶冠宇
2023-03-14

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

章哲茂
2023-03-14

我和卡拉夫也有同样的问题。到目前为止,我找到的唯一解决方案是将动态导入设置为hibernate捆绑包级别。我不确定这是最好的解决方案

 类似资料:
  • 问题内容: 我已经为此厌倦了很长时间。我不知道是什么原因导致此错误。这是我的文件: Uzytkownik.hbm.xml hibernate.cfg.xml: 我使用的是MySQL 5.5。 我收到以下错误: 这是我的课程:main.java Uzytkownik.java: HibernateUtil.java: 问题答案: 也许您的映射文件不完整,但其他方面应该是: =>需要设置完全合格的类名

  • 问题内容: 我将开始一个使用Spring和Hibernate管理的REST应用程序项目。 我知道Spring允许您从HTTP Request(带有注释)中获取Java对象。如果此Java对象也是Hibernate实体,是否有冲突?嵌套对象是否起作用(如关系)? 问题答案: 我们正在使用这种方法来简化设计并摆脱许多dto(我们滥用它们太多了)。基本上,它对我们有用。 但是,在我们的REST模型中,我

  • 问题内容: 我正在使用Hibernate和JPA。我有一个实体,它引用了: 但是在我的数据库中,有些客户没有父母,因此将设置为。我在测试班级时遇到的异常是: 有没有一种方法来设置,以当id为? 问题答案: 尝试这个

  • 假设我有一个对象,该对象应包含(政府 ID)对象。我正在从乘客获取。创建对服务器的请求并获取数据(json),而不是解析接收的数据并存储在存储库中。 我很困惑,因为我想将< code>Passport存储为实体,并将其放入< code>PassportRepository中,但所有关于密码的信息都包含在json中,而不是我在上面收到的信息。 我想我应该使用作为 VO 并将其放入(聚合)对象中。或者

  • 我使用javax.validation和Hibernate验证器实现了一些代码。使用验证的单元测试工作良好。该构建生成OSGi包和特性,并在Karaf中运行。 “无法创建配置,因为找不到Bean验证提供程序。请将Hibernate Validator(RI)这样的提供程序添加到类路径中。” 我会包括stacktrace,但它对我来说没有什么用。大部分都在我的代码、junit和Paxexam中。 我

  • 问题内容: 请帮助我,我是Maven项目的初学者,我尝试使用hibernate连接到我的MySQL数据库,但是出现此错误。如果有人可以帮助我,它将非常友好! 这是我用于hibernate的spring-database.xml 我的web.xml 我的webmvc-dispatcher-servlet 和我的pom.xml 谢谢你的回答 问题答案: 您的Spring版本是4.1.7.RELEASE