Q:

Mongo DB Glassfish Server Error Class not found

I am getting an error while executing a glassfish server with use of MongoDB:

java.lang.NoClassDefFoundError: com/mongodb/client/MongoCollection 

I have the following dependencies :
<dependencies>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet -->
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
    <version>2.26</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson -->
<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.26</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19.4</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>RELEASE</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver -->
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver</artifactId>
        <version>3.6.1</version>
    </dependency>

</dependencies>

The specific jars are definitly imported, and while compilation there is also occurring no error. I have looked up for solutions here already but none of them helped me. So if anyone might see the error, pleaser tell me. Thanks in advance. 

A:

It looks like you should use this dependency:
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.6.1</version>
</dependency>

If this doesn't work alternatively you can put the mongodb-driver JAR into /glassfish/glassfish4/lib/.

