Morphia gives NoClassDefFoundError: com/mongodb/DBObject? - mongodb

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?

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

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).

Related

Eclipse IDE: java.lang.IllegalArgumentException: Not an managed type

I'm trying to deploy an EAR application on a Weblogic 10.3.3 server. When using the Weblogic admin-console on http://localhost:7001/console/, it works fine. When using Intellij IDEA, it works fine.
However, when deploying from Eclipse Mars, I have the following error, caused by Spring JPA:
Caused By: java.lang.IllegalArgumentException: Not an managed type: class package.xxx.MyClass
at org.hibernate.ejb.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:171)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:149)
at investmentcafe.ngs.dao.BaseRepositoryFactoryBean$NGSRepositoryFactory.getTargetRepository(BaseRepositoryFactoryBean.java:34)
I'm using Spring 3.2.14.RELEASE, with Spring-data-jpa 1.6.6.RELEASE. The problem occurs on Eclipse Mars.1 (4.5.1 build 20150924-1200), with the Oracle WebLogic Server Tools version 8.4.0.201510191754. I'm deploying "as a virtual application" from the Weblogic tools.
I'm quite puzzled by this strange behavior. Any ideas on how to explain such Eclipse-specific behavior and/or on how to troubleshoot/fix it?
It seems that moving the hibernate .xml file in the META-INF folder fixed the problem. (So the persistence.xml can be renamed, but cannot be moved #GiveEclipseSomeLove)

How to solve SplitsrcTargetPreparation exception in Oracle weblogic server?

I am trying to run a simple Restful web service example on oracle weblogic server . but i am getting this issue while run the project on server. Publishing to Oracle Weblogic server at localhost has encountered a problem.Runtime exception occurred in publish task 'SplitsrcTargetPreparation'.
Have a look on screen sort.What i have to do ?
None of the other answers solved my problem, but I finally found a solution. I'm not claiming that this is the best or only way of resolving this issue, but it worked for me. Hope it helps others.
Open the Properties of your WebLogic server instance in Eclipse. Select Publishing. Set the publishing mode to "Publish as an exploded archive". You will no longer get a split source error.
Check the following.
Maven version – If you have imported as a maven project then make
sure that maven version is compatible to the java version you are
using.
Makes sure that you are using the java from the Middleware
which is comes bundled with weblogic.
New domain – Corrupt domain
may also cause this. Create a new domain

Oracle Driver not found

My tomcat web app isn't loading the oracle driver any longer. I moved tomcat and messed with the server definition. Its up and running but can't connect to Oracle due to a missing driver.
I had similar problem with log4j and other libs but adding the lib into the Deployment Assembly of the web app properties solved those issues.
The Oracle lib is there as is its odbc6.jar.
I also tried copying it to WEB-INF/lib with to no avail.
I have a hunch this is a class path problem but I'm not sure how to fix it. I'm also concerned that tomcat can find other libs but not the oracle liv.
SQLException: No suitable Driver Found for jdbc:oracle:thin:#//localhost:1521/orcl
Fixed. I removed the server from the eclipse server window. Clean the project. Added the server back in. Cleaned and rebuild and it worked.

Deploying WAR File to Glassfish

I'm just getting to grips with the NetBeans 6.9 / Glassfish 3 combo, and have developed a Java EE app consisting of a WAR module and an EJB module. Having played around with the EJB side of things for a while, I went back to run the web code, and started having problems.
When I try to run the WAR file, it fails to deploy, and the error from the server is `WEB0113: virtual server [server] already has a web module [MyApp-war.war] loaded.' But I haven't edited the web side code since I last ran it, and I'm rather puzzled as to what it's trying to do.
I've tried the usual things: restarting the server, undeploying and redeploying the application, but to no avail... so if anyone with any more experience with Glassfish has any hints, they will be gratefully received!
if anyone with any more experience with Glassfish has any hints, they will be gratefully received!
Open GlassFish's Admin Console, see if the application is listed and try to undeploy it from there.
Did you create and deploy an enterprise application (ear) containing the ejb and web module? I don't think you can then deploy only the webapplication since its already deployed inside the ear. You'll have to redeploy the ear instead.
I had the same problem. Restart of glassfish server helped.
What was interesting, the Applications list did not have the application. Apparently some glassfish/netbeans bug.
What I did was , i went to the admin console for my Glassfish server and I undeployed all the unused projects and redeployed the project that i was trying to run. And it worked!

Java EE6 App + EJB in Glassfish 3.0/Netbeans 6.8?

Has anyone got this configuration working?
Latest Netbeans, latest Glassfish, I created an EJB project, also an EE Application.
The EJB in itself builds & deploys to Glassfish OK.
Now when I want to reference the EJB, I have to add the EJB jar to the EE Application path, if I don't do this the code does not compile.
But, the EJB jar gets packaged in the App jar and as a result when I try to deploy the app to Glassfish it says:
"java.lang.IllegalArgumentException:
Sniffers with type [ejb] and type
[appclient] should not claim the
archive at the same time. Please check
the packaging of your archive"
How do I tell Netbeans NOT TO package the EJB in the App jar? Or is the problem somewhere else?
btw. if I remove the EJB manually from the JAR then the app deploys successfully (with asadmin deploy), but when I try to run it with appclient, I get a NullPointerException.
Surely there must be a solution to this, I thought Netbeans was for web application development after all...
Edit: I found this:
http://forums.netbeans.org/topic23499.html
Which lists exactly the same steps that I did to resolve the problem.
Here is a solution candidate:
https://netbeans.org/bugzilla/show_bug.cgi?id=183488
Which basically says that Glassfish v3 is seriously broken, and it won't work.
Here is how I got it to work: the EJB and the EE Application MUST BE packaged in an EAR (project), and they MUST BE deployed within the EAR. Deploying the application jar individually WILL NOT WORK (at least not with Netbeans 6.8 + Glassfish v3).