[英]hibernate ogm Could not obtain JBoss Transactions transaction manager instance
I'm trying to run hibernate ogm in standalone mode (not jee container). 我正在尝试以独立模式(不是jee容器)运行休眠ogm。 my persistence.xml file is the following
我的persistence.xml文件如下
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="primary" transaction-type="JTA">
<!-- Use Hibernate OGM provider: configuration will be transparent -->
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.ogm.datastore.provider" value="infinispan"/>
<property name="hibernate.ogm.mongodb.database" value="Heroku Read Only"/>
<property name="hibernate.ogm.mongodb.host" value="host"/>
<property name="hibernate.ogm.mongodb.port" value="99999"/>
<property name="hibernate.ogm.mongodb.username" value="user"/>
<property name="hibernate.ogm.mongodb.password" value="pass"/>
</properties>
</persistence-unit>
</persistence>
in my main i added the following code 在我的主要我添加了以下代码
private static EntityManagerFactory entityManagerFactory;
public static void main(String[] args){
entityManagerFactory = Persistence.createEntityManagerFactory( "primary" );
EntityManager entityManager = entityManagerFactory.createEntityManager();
}
when I run my main I get the following exception 当我运行主程序时,出现以下异常
Exception in thread "main" org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException: Could not obtain JBoss Transactions transaction manager instance
线程“主”中的异常org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException:无法获取JBoss Transactions事务管理器实例
here after all the log 毕竟这里日志
janv. 06, 2017 5:04:13 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation INFO: HHH000204: Processing PersistenceUnitInfo [
name: primary
...] janv. 06, 2017 5:04:13 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.0.1.Final} janv. 06, 2017 5:04:13 PM org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found janv. 06, 2017 5:04:13 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist janv. 06, 2017 5:04:13 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} janv. 06, 2017 5:04:15 PM org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator initiateService INFO: OGM000016: NoSQL Datastore provider: org.hibernate.ogm.datastore.infinispan.impl.InfinispanDatastoreProvider janv. 06, 2017 5:04:15 PM org.hibernate.ogm.transaction.impl.OgmJtaPlatformInitiator initiateService INFO: OGM000075: JBoss Transaction Manager (com.arjuna.ats.jta.TransactionManager) detected on classpath. Using JBossStandAloneJtaPlatform as JTAPlatform implementation janv. 06, 2017 5:04:15 PM org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator newInstance INFO: OGM000017: Grid Dialect: org.hibernate.ogm.datastore.infinispan.InfinispanDialect janv. 06, 2017 5:04:15 PM org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator newInstance INFO: Grid dialect logs are disabled janv. 06, 2017 5:04:15 PM org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.ogm.dialect.impl.OgmDialect janv. 06, 2017 5:04:15 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl makeLobCreatorBuilder INFO: HHH000422: Disabling contextual LOB creation as connection was null janv. 06, 2017 5:04:15 PM org.hibernate.ogm.cfg.impl.Version <clinit> INFO: OGM000001: Hibernate OGM 5.0.0.CR1 Exception in thread "main" org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException: Could not obtain JBoss Transactions transaction manager instance
at org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform.locateTransactionManager(JBossStandAloneJtaPlatform.java:35)
at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.retrieveTransactionManager(AbstractJtaPlatform.java:87)
at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.getTransactionManager(AbstractJtaPlatform.java:98)
at org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerBasedSynchronizationStrategy.canRegisterSynchronization(TransactionManagerBasedSynchronizationStrategy.java:39)
at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.canRegisterSynchronization(AbstractJtaPlatform.java:131)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.pulse(JtaTransactionCoordinatorImpl.java:141)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.<init>(JtaTransactionCoordinatorImpl.java:92)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildTransactionCoordinator(JtaTransactionCoordinatorBuilderImpl.java:28)
at org.hibernate.internal.SessionImpl.<init>(SessionImpl.java:273)
at org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl.openSession(SessionFactoryImpl.java:1322)
at org.hibernate.ogm.hibernatecore.impl.OgmSessionBuilderDelegator.openSession(OgmSessionBuilderDelegator.java:39)
at org.hibernate.ogm.hibernatecore.impl.OgmSessionBuilderDelegator.openSession(OgmSessionBuilderDelegator.java:25)
at org.hibernate.jpa.internal.EntityManagerImpl.internalGetSession(EntityManagerImpl.java:133)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:174)
at org.hibernate.jpa.internal.EntityManagerImpl.<init>(EntityManagerImpl.java:83)
at org.hibernate.jpa.internal.EntityManagerFactoryImpl.internalCreateEntityManager(EntityManagerFactoryImpl.java:319)
at org.hibernate.jpa.internal.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:286)
at org.hibernate.ogm.jpa.impl.OgmEntityManagerFactory.createEntityManager(OgmEntityManagerFactory.java:45)
at com.energielibre.middleware.service.mongodatalayergeneric.Tester.main(Tester.java:26) Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform.locateTransactionManager(JBossStandAloneJtaPlatform.java:32)
... 18 more Caused by: java.lang.RuntimeException: java.lang.RuntimeException: missing property file arjuna-properties.xml
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(BeanPopulator.java:81)
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getDefaultInstance(BeanPopulator.java:49)
at com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean(jtaPropertyManager.java:42)
at com.arjuna.ats.jta.TransactionManager.transactionManager(TransactionManager.java:72)
... 23 more Caused by: java.lang.RuntimeException: missing property file arjuna-properties.xml
at com.arjuna.common.util.propertyservice.PropertiesFactory.getPropertiesFromFile(PropertiesFactory.java:93)
at com.arjuna.common.util.propertyservice.PropertiesFactory.initDefaultProperties(PropertiesFactory.java:236)
at com.arjuna.common.util.propertyservice.PropertiesFactory.getDefaultProperties(PropertiesFactory.java:66)
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(BeanPopulator.java:77)
... 26 more
my dependencies are 我的依赖是
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<!-- JBoss Transactions dependency -->
<dependency>
<groupId>org.jboss.jbossts</groupId>
<artifactId>jbossjta</artifactId>
<version>4.16.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-mongodb</artifactId>
<version>5.0.0.CR1</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-infinispan</artifactId>
<version>5.0.0.Alpha1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
There are some problems with the configuration and I'm not sure if it's related to your issue. 配置存在一些问题,我不确定是否与您的问题有关。
You set hibernate.ogm.datastore.provider
to infinispan
but then you set hibernate.ogm.mongodb.database
. 您将
hibernate.ogm.datastore.provider
设置为infinispan
,然后再设置hibernate.ogm.mongodb.database
。 Are you trying to work with Infinispan or MongoDB? 您是否要使用Infinispan或MongoDB?
You are using an old dependency, you should try Hibernate OGM 5.0.4.Final 您正在使用旧的依赖项,则应尝试使用Hibernate OGM 5.0.4.Final
All the properties you set with hibernate.ogm. 您使用hibernate.ogm设置的所有属性。 mondogb .* are wrong, you should use hibernate.ogm.
mondogb 。*错误,您应该使用hibernate.ogm。 datastore .*.
资料储存库 。*。 Check the documentation for the specific properties for the db you are using
检查文档以获取正在使用的数据库的特定属性
You can also try to replace jbossjta dependency with: 您也可以尝试将jbossjta依赖项替换为:
org.jboss.narayana.jta narayana-jta 5.4.0.Final org.jboss.narayana.jta narayana-jta 5.4.0。最终版
You don't need a datasource because you are not dealing with Relational Databases. 您不需要数据源,因为您不处理关系数据库。 Hibernate OGM take the information from the configuration and its own dialects.
Hibernate OGM从配置及其自己的方言中获取信息。
Let me know if the problem persists. 让我知道问题是否仍然存在。
EDIT: Added point 4 编辑:添加点4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.