MongoSocketReadException when used Hibernate OGM with cloud MongoDB Atlas

Description

I was asked this question on https://stackoverflow.com/questions/54487413/usage-of-hibernate-ogm-with-cloud-mongodb-atlas-m0-free-tier/54532599#54532599

I am trying to use MongoDB Atlas M0 (Free Tier) for my JAVA EE application, now I am using:

  • Local MongoDB database (v4.0.4)

  • Hibernate Core "hibernate-core 5.3.6.Final"

  • Hibernate OGM "hibernate-ogm-mongodb 5.3.1.Final"

  • Java application server WildFly 15.0.0.Final

When I tried to connect Hibernate with Mongo Atlas to test cloud database, I am was not able to have a working connection, because mongodb driver throws an exception com.mongodb.MongoSocketReadException: Prematurely reached end of stream

My persistence.xml that causes the error:

As @Davide D'Alto suggested I create Factory to interact for the persistence unit

Environment

None

Status

Assignee

Unassigned

Reporter

name surname

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

Priority

Major
Configure