How can i solve a NoClassDefFoundError?

Alexandros picture Alexandros · Jun 13, 2012 · Viewed 19.1k times · Source

I have installed Oracle Weblogic 11g on Oracle Linux and I tried to complete one of Oracle's ADF tutorials using jdeveloper 11g. When I run my project it compiles successfully with no errors. It starts deploying the application to the weblogic server and my default internet browser opens. But then an Error "500 Internal server error" appears.

I'm getting the following error:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.myfaces.trinidadinternal.convert.ColorConverter at....

I researched the internet for this problem and I also asked around and the common answer was that there is a problem with the classpath. Probably the libraries that are used in jdeveloper are not the same in weblogic then the project gets deployed.

Can anyone tell if definitely the problem is the classpath?? And how can I setup jdeveloper to deploy the same classpath it used to the weblogic server?

Answer

JoseK picture JoseK · Jun 14, 2012

java.lang.NoClassDefFoundError means the runtime version of the class in the classpath is not the same as that at compile time.

Your problem could be multiple versions of the class being found when the server is deploying. I notice the class org.apache.myfaces.trinidadinternal.convert.ColorConverter is found in trinidad-impl.jar

Can you search for how many such jars are found in the run time server environment plus your own webapp libraries?

On windows, the Jdev inbuilt server runs in this folder

C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23 or something similar

you need this in your webapp/WEB-INF/lib and not in the other areas.

On my local I find the Jar under C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\o.j2ee.wlLibs\jsp\Trinidad-Components1.2.war

I think you could use the weblogic.xml setting to force the WEB-INF/lib class to get loaded in preference to that in server/lib with

    <container-descriptor>     
<prefer-web-inf-classes>true</prefer-web-inf-classes>   
</container-descriptor>