Question

I run Morphia 0.102 with the Mongo Java Client 2-11.2.

This is a client / server app. At the moment I test the server side locally on GlassFish.

Ok, when I run some code on the client, using Mongo and Morphia, no issue. Then when some code is called on the server side, it instantiates Morphia on the server with

        mongoClient = new MongoClient("199.00.000.000", 27017);
        morphia = new Morphia(); //exception thrown

The exception:

Caused by: java.lang.NoClassDefFoundError: com/mongodb/DBObject  
    at com.google.code.morphia.Morphia.<init>(Morphia.java:48)  
    at com.google.code.morphia.Morphia.<init>(Morphia.java:44)  

I've spent several hours trying to change the versions of Morphia and the MongoDriver, with no result and I have no clue.

Any idea?

Was it helpful?

Solution 2

So, adding the jar in the glassfish folder solved this exception when I was running GlassFish locally, from Netbeans. The issue came back when I uploaded my Java EE module on the server.
Adding the mongo and morphia jars in all kinds of folders did not solve anything then. The thing that solved it :
- I integrated my Java EE module into an EAR, then deployed the EAR (before that I was only deploying the Java EE Module without an EAR - surely a very bad practice, but I did not know).

OTHER TIPS

Are you including the morphia jar in your war file? Adding things to that glassfish folder is almost always the wrong answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top