Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
MongoDB driver 4.4.0 throws UnsupportedAddressTypeException with Java 17

I have problems with the latest mongodb driver 4.4.0 on my Linux machine with Java 17. It throws following exception:

  Exception java.io.UncheckedIOException: java.net.SocketException: Unsupported address type
        at DatagramSocketAdaptor.connect (DatagramSocketAdaptor.java:120)
        at DatagramSocket.connect (DatagramSocket.java:474)
        at DnsClient.doUdpQuery (DnsClient.java:408)
        at DnsClient.query (DnsClient.java:214)
        at Resolver.query (Resolver.java:81)
        at DnsContext.c_getAttributes (DnsContext.java:434)
        at ComponentDirContext.p_getAttributes (ComponentDirContext.java:235)
        at PartialCompositeDirContext.getAttributes (PartialCompositeDirContext.java:141)
        at PartialCompositeDirContext.getAttributes (PartialCompositeDirContext.java:129)
        at InitialDirContext.getAttributes (InitialDirContext.java:171)
        at DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords (DefaultDnsResolver.java:114)
        at ConnectionString.<init> (ConnectionString.java:388)
        at (#5:1)
  Caused by: java.net.SocketException: Unsupported address type
        at Net.translateToSocketException (Net.java:187)
        at DatagramSocketAdaptor.connectInternal (DatagramSocketAdaptor.java:95)
        at DatagramSocketAdaptor.connect (DatagramSocketAdaptor.java:118)
        ...
  Caused by: java.nio.channels.UnsupportedAddressTypeException
        at Net.checkAddress (Net.java:161)
        at DatagramChannelImpl.connect (DatagramChannelImpl.java:1217)
        at DatagramSocketAdaptor.connectInternal (DatagramSocketAdaptor.java:91)
        ...

It works as expected on my Windows with Java 17 and also on that Linux with Java 11.

How do I test it:

$ jshell --class-path mongodb-driver-core-4.4.0.jar

jshell> import com.mongodb.ConnectionString;

jshell> ConnectionString cs = new ConnectionString("mongodb+srv://xyz.mongodb.net/");

Expected result is javax.naming.NameNotFoundException: DNS name not found, however actual result is the java.nio.channels.UnsupportedAddressTypeException.

Any idea how to make it work?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

After a lot of "jdbing" I found out, that I can make it work with older implementation of DatagramSocketImpl as is stated here https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/net/DatagramSocketImpl.html

I.e. if I set jdk.net.usePlainDatagramSocketImpl system property to "true" then it works.

Although I don't know proper solution or the real cause of the problem, I can live with the workaround and it works for me.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!