繁体   English   中英

启动服务时出现JPA休眠错误

[英]Jpa-hibernate error while starting the service

以下是启动服务后看到的日志错误...您能帮助解决此问题吗?

2013-08-22 10:35:37,111 | DEBUG | l Console Thread | AbstractServiceReferenceRecipe   | r.AbstractServiceReferenceRecipe  143 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Found initial references null for OSGi service (&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=tenant))(objectClass=javax.persistence.EntityManagerFactory))

2013-08-22 10:35:37,111 | DEBUG | l Console Thread | BlueprintContainerImpl           | container.BlueprintContainerImpl  280 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Running blueprint container for bundle com.igt.arcus.framework.jta.arcus-framework-feature-service in state WaitForInitialReferences
2013-08-22 10:35:37,111 | INFO  | l Console Thread | BlueprintContainerImpl           | container.BlueprintContainerImpl  344 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Bundle com.igt.arcus.framework.jta.arcus-framework-feature-service is waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=tenant))(objectClass=javax.persistence.EntityManagerFactory))]
2013-08-22 10:35:37,112 | DEBUG | l Console Thread | BlueprintEventDispatcher         | ntainer.BlueprintEventDispatcher  136 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Sending blueprint container event BlueprintEvent[type=GRACE_PERIOD, dependencies=[(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=tenant))(objectClass=javax.persistence.EntityManagerFactory))]] for bundle com.igt.arcus.framework.jta.arcus-framework-feature-service

如果您使用Aries JPA,则应该看到两个EntityManagerFactory服务:

  • jpa-container使用persistence.xml拾取捆绑包,并创建一个实体管理器工厂
  • jpa-container-context拾取每个EntityManagerFactory服务,并使用(org.apache.aries.jpa.proxy.factory = true)服务属性键值对创建新的托管EntityManagerFactory服务。

第二个在您的环境中不存在。 可能有两个原因:

  • aries-jpa-container-context不在您的OSGi环境中,也不处于ACTIVE状态
  • 原始EntityManagerFactory服务未注册,因为缺少某些依赖项

如果打开OSGi控制台并检查可用的服务,则可以检查它。 如果根本没有EntityManagerFactory服务,第二个是您的问题。

检查所有捆绑包是否都处于活动状态! 如果是,请检查是否具有jpa-container所需的所有服务:TransactionManager,DataSource或DataSourceFactory以及用于Hibernate的javax.persistence.spi.PersistenceProvider服务。 如果缺少任何服务,aries-jpa-container将会拾取您的捆绑包,但将永远不会创建EntityManagerFactory。

我实现了自己的jpa容器,其工作方式与aries-jpa-container几乎相同。 如果替换aries-jpa-container(仅保留一个,则应在其中保留jpa-container-context),它将为您记录更多信息,以供您参考。 容器在这里可用。 https://github.com/everit-org/osgi-hibernate上提供了一个使用休眠的示例应用程序。 运行“ mvn install”后,您会发现itests / core / target / eosgi-itests-dist / equinox一个子文件夹,您可以在其中用bin / runco​​nsole.sh在Equinox服务器上启动正在运行的应用程序。

当前的白羊座jpa容器jar 1.0.0有一个错误,使它在创建EntityManager时吞下了异常。 我的一位同事打开了白羊座的bug: https ://issues.apache.org/jira/browse/ARIES-1160

我创建了第二个补丁,该补丁可以应用于1.0.0源,以创建一个可以正确记录异常的jar。 签出aries jpa容器的1.0.0标签,应用补丁并构建。

然后在karaf中运行时,您应该会看到错误的真正来源。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM