I'm trying to run hibernate ogm in standalone mode (not jee container). my persistence.xml file is the following
<?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
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
toinfinispan
but then you sethibernate.ogm.mongodb.database
. Are you trying to work with Infinispan or MongoDB?You are using an old dependency, you should try Hibernate OGM 5.0.4.Final
All the properties you set with hibernate.ogm.mondogb.* are wrong, you should use 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:
org.jboss.narayana.jta narayana-jta 5.4.0.Final
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.
Let me know if the problem persists.
EDIT: Added point 4