简体   繁体   中英

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:

  • 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

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: 在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM