Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Eclipse Link 4.0.0/MongoDB 6.0.1 unable to connect authSource param missing.(Eclipse Link cannot connect to MongoDB with user and password because cannot pass authSource params)
Eclipse Link 4.0.0/MongoDB 6.0.1 unable to connect authSource param missing. [message #1856688] Thu, 22 December 2022 16:19 Go to next message
Eclipse UserFriend
Hello everybody.

I am trying to connect to MongoDB version 6.0.1. This server is configured to use the user and password.

I cannot be able to connect. In little research on the internet, the problem is related to the authSource=admin param. But I cannot find any about how to pass custom params using the persistent.xml

I read in sprint data

spring.data.mongodb.authentication-database=admin

spring.data.mongodb.uri=mongodb://user:passwod@localhost/test?authSource=admin

But in EclipseLink?

Any way to send custom parameters in the connection config of persistent.xml?

My persistence.xml look like

<persistence 
    ....
    version="2.1">
    <persistence-unit name="Support" transaction-type="RESOURCE_LOCAL">
        <class>com.jpa.example.models.NoSQL.MyObject</class>
        <properties>
            <property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
            <property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.Mongo3ConnectionSpec"/>
            <property name="eclipselink.nosql.property.user" value="root"/>
            <property name="eclipselink.nosql.property.password" value="dsystems01"/>
            <property name="eclipselink.nosql.property.mongo.port" value="27017"/>
            <property name="eclipselink.nosql.property.mongo.host" value="localhost"/>
            <property name="eclipselink.nosql.property.mongo.db" value="Test01DB"/>
            <property name="eclipselink.nosql.property.mongo.auth-source" value="admin"/>

            <property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create" />

            <property name="eclipselink.logging.level" value="FINEST"/>
        </properties>
    </persistence-unit>
</persistence>


I really appreciate any help you can provide.
Re: Eclipse Link 4.0.0/MongoDB 6.0.1 unable to connect authSource param missing. [message #1856753 is a reply to message #1856688] Wed, 28 December 2022 14:52 Go to previous messageGo to next message
Eclipse UserFriend
It looks like a newer setting/option that wasn't always supported in the MongoClient.

I'm not overly familiar with that part of the code, but you might be able to write your own mechanisms to read in that property if you look at MongoConnectionSpec.java and MongoDatabaseConnectionFactory.java and how they build a com.mongodb.MongoClient from com.mongodb.MongoClientOptions. The latest Mongo client may support the authSource in its options, or you can use a MongoClientURI as shown in post https://stackoverflow.com/questions/46156343/mongodb-url-set-with-mongoclientoptions .

Best Regards,
Chris
Re: Eclipse Link 4.0.0/MongoDB 6.0.1 unable to connect authSource param missing. [message #1856789 is a reply to message #1856753] Mon, 02 January 2023 18:35 Go to previous message
Eclipse UserFriend
Hello, thanks for your answer!

But I read the source code and the param is missing the class MongoConnectionSpec and MongoJCAConnectionSpec does not take care of the "authSource" parameter.

I summited a pull request fixing the missing feature you can see in:

https://github.com/eclipse-ee4j/eclipselink/pull/1770
Previous Topic:Unable to download EclipseLink 4.0 Documentation PDFs
Next Topic:spring configuration for eclipselink spring-data jpa
Goto Forum:
  


Current Time: Thu Jul 10 00:16:56 EDT 2025

Powered by FUDForum. Page generated in 0.20363 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top