1

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:

  • MANIFEST.MF
  • PhillPlugin.class - line 118 gives me the error only on the server
  • PhillPlugin.xml

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Phill Alexakis
  • 1,449
  • 1
  • 12
  • 31
  • Possible duplicate of [java.lang.NoClassDefFoundError: org/json/JSONObject](https://stackoverflow.com/questions/27504508/java-lang-noclassdeffounderror-org-json-jsonobject) – SatyaTNV Jul 29 '19 at 09:25
  • i've seen it, it's different for OAM server, i need to refer to it through my `manifest.mf` file, just by including it on my project won't fix the problem. – Phill Alexakis Jul 29 '19 at 09:26
  • By the looks of it, you should list package names, but instead you are also listing class names. – Mark Rotteveel Jul 29 '19 at 15:31

1 Answers1

1

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

Phill Alexakis
  • 1,449
  • 1
  • 12
  • 31