-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Error when configuring 2 entityManager (OGM and ORM)
PostPosted: Fri Jun 16, 2017 12:20 pm 
Newbie

Joined: Fri Jun 16, 2017 6:22 am
Posts: 3
Hello guys,

I come across with a big issue.
I am trying to configure 2 entityManager in my Spring MVC app : 1 for MySQL and 1 for MongoDB.
When I use hibernate-core version : 5.2.8.Final with hibernate-ogm-core : 5.1.0.Final, I have this exception :
Code:
  java.lang.NoClassDefFoundError: org/hibernate/resource/transaction/TransactionCoordinatorBuilder

I googled and found that this is due to dependencies compatibility.
I try to downgrade these versions like here : https://github.com/hibernate/hibernate-ogm/blob/5.0.1.Final/bom/pom.xml#L43
but it raised another exception :
Code:
    java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;

Here my entityManager configuration :
Code:
@Configuration
@EnableJpaRepositories( basePackages = "com.app.persistence.mongo.repository", entityManagerFactoryRef = "mongoEntityManager" )
public class MongoDBConfig {

    @Bean( name = "mongoEntityManager" )
    public LocalContainerEntityManagerFactoryBean mongoEntityManagerFactory() {

        // ====HIBERNTATE OGM PROPERTIES=======
        Map<String, Object> properties = new HashMap<>();
        properties.put( OgmProperties.DATASTORE_PROVIDER,
                MongoDBDatastoreProvider.class );
        properties.put( OgmProperties.HOST, "localhost:27017" );
        properties.put( OgmProperties.DATABASE, "starter" );
        properties.put( OgmProperties.CREATE_DATABASE, "true" );

        LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
        entityManagerFactoryBean.setPackagesToScan(
                "com.app.persistence.mongo.entities" );
        entityManagerFactoryBean.setPersistenceProviderClass( HibernateOgmPersistence.class );
        entityManagerFactoryBean.setJpaPropertyMap( properties );

        return entityManagerFactoryBean;
    }

    @Bean
    public JpaTransactionManager transactionManager() {
        return new JpaTransactionManager( mongoEntityManagerFactory().getObject() );
    }

}

When I disable this entityManager configuration and using hibernate-core 5.2.8.Final it works fine but I can only persist data in MySql database.
Could someone guide me?
Thanks a lot.


Top
 Profile  
 
 Post subject: Re: Error when configuring 2 entityManager (OGM and ORM)
PostPosted: Fri Jun 23, 2017 6:16 am 
Newbie

Joined: Fri Jun 16, 2017 6:22 am
Posts: 3
I finally found the reason of those exceptions.
Just non-compatible dependencies versions.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.