I was using without any Mongo beans instantiation issue a Java maven project with Java 8 and Spring Data MongoDb Reactive. Currently, I’m trying to upgrade the same project from Java 8 project to Java 11 (jvm 11.0.8+10-LTS). My updated spring boot version is 2.5.6 with Jetty server (9.4.44.v20210927), and the corresponding Mongo reactive version is based on 2.5.6. When Spring is trying to create the mongo related beans in order to add them in the context the following error appears:
Unable to support mongodb+srv// style connections as the ‘com.sun.jndi.dns.DnsContextFactory’ "
+ "class is not available in this JRE. A JNDI context is required for resolving SRV records
Among others I've tried the following:
add a jndi.properties file that sets a property
java.naming.provider.url=dns:.
add -exports argument to the maven compiler plugin
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<compilerArgs>
<arg>--add-exports</arg>
<arg>jdk.naming.dns/com.sun.jndi.dns=java.naming</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
upgraded to the latest jetty server version compatible with java 11
<jetty.version>9.4.44.v20210927</jetty.version>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
Can you please advise me with a solution?