Mongo-java-driver: NoClassDefFoundError

Hello, according to the documentation of the Mongo Java driver, the driver will use SLF4J if the driver detects the presence of SLF4J API in the classpath. Otherwise, the driver will log a single warning via JUL and otherwise logging will be disabled (here). However, when using the driver when SLF4J is not present in the classpath, I have missing dependency errors:


I was wondering what I did wrong, if I missed anything. Thanks in advance for your answers!

Hello @Romain_N_A, welcome to the MongoDB Community forum!

I see from your stack trace, you are using MongoDB Reactive Streams Java Driver APIs. I had used the same driver (v1.13.1) as per the installation instructions and was able to run my sample code (access a MongoDB database collection using reactive streams API) without any errors. The driver did use Java Util Logging (JUL) without any configuration. I had used only the <artifactId>mongodb-driver-reactivestreams</artifactId> dependency in my pom.xml.

You can include some information about your Maven dependencies and the code where the exception is occurring.

Hi @Romain_N_A ,

Thanks for reporting, that is a bug in the vendored tls async library. I’ve filed JAVA-4201 to get that fixed so logging will work in the same way as the rest of the driver.

In the meantime please add a dependency to slf4j.

Ross

1 Like

Hello, thank you very much for your answer!

On my side, I made a fork of the driver and fixed it myself.
I would like to point out that the problem is not only with the AsynchronousTlsChannelGroup class, but also with the ServerTlsChannel, TlsChannelImpl, DirectBufferDeallocator and Util classes which were using the SLF4J logger directly. :grinning_face_with_smiling_eyes:

Have a nice day!

As you can see here, the driver uses directly the SLF4J library as logger. It’s strange that it worked on your side :thinking: