Phill Alexakis
Phill Alexakis

Reputation: 1499

java.lang.NoClassDefFoundError: org/json/JSONObject when Java Class runs on OAM Server

I'm getting java.lang.NoClassDefFoundError: org/json/JSONObject when i'm running my .class on Oracle Access Manager

This is the stacktrace:

java.lang.NoClassDefFoundError: org/json/JSONObject
at phillplugin.PhillPlugin.process(PhillPlugin.java:118)

PhillPlugin.java:118 contains just a creation of an instance of a JSONObject

//Line 118:
 JSONObject x = new JSONObject();

I'm using JDeveloper IDE and i have included the org.json.jar in my Libraries and in my Deployment profile

Note that when i'm executing it from a simple main.class it runs perfectly

I have to include the org.json.jar in the MANIFEST.MF file of the deploying PhillPlugin.jar and i have done it as follows:

Manifest-Version: 1.0
Bundle-Version: 10
Bundle-Name: PhillPlugin
Bundle-Activator: phillplugin.PhillPlugin
Bundle-ManifestVersion: 2
Import-Package: 
 org.osgi.framework;version="1.3.0",
 oracle.security.am.plugin,
 oracle.security.am.plugin.authn,
 oracle.security.am.plugin.impl,
 oracle.security.am.plugin.api,
 oracle.security.am.common.utilities.principal,
 oracle.security.idm,
 javax.security.auth,
 org.json.JSONObject;resolution:=optional,
 org.json.JSONArray;resolution:=optional,
 org.json;resolution:=optional
Export-Package: 
 org.json.JSONObject;resolution:=optional,
 org.json.JSONArray;resolution:=optional,
 org.json;resolution:=optional
Bundle-SymbolicName: PhillPlugin
Bundle-ClassPath: org.json.jar,utilities.jar,oam-plugin.jar,felix.jar,identity-provider.jar

But still the server does not recognise my imports

Let me mention that the PhillPlugin.jar contains:

I will be happy to provide you with any other extra information you need

Upvotes: 1

Views: 677

Answers (1)

Phill Alexakis
Phill Alexakis

Reputation: 1499

I had to include the external library in both MANIFEST.MF(reference) as i correctly did, and also the org.json.jar in the final PhillPlugin.jar as well as the json libraries This way the server was able to see my imports

Here is the sample that worked for me: enter image description here

Note that, the exception was being triggered even if the org folder was missing or the org.json.jar was missing

Upvotes: 1

Related Questions