-1

I am converting json string to JSONOBJECT and i use import org.json.JSONObject but i use this

String jsonString = "{\"stat\": { \"sdr\": \"aa:bb:cc:dd:ee:ff\", \"rcv\": \"aa:bb:cc:dd:ee:ff\", \"time\": \"UTC in millis\", \"type\": 1, \"subt\": 1, \"argv\": [{\"type\": 1, \"val\":\"stackoverflow\"}]}}"; JSONObject jsonObject = new JSONObject(jsonString);

result: i get error

'Handler proccessing failed; nestedexception is java.lang.NoClassDefFoundError: org/json/JSONObject'

i have json-20170516.jar into spring-mvc project and i run this project in tomcat server. i have onother project simple java project and using above code for this simple java project and thisworked correctly. i'm confusing for above problem.

yaghob abbasi
  • 96
  • 1
  • 12

1 Answers1

-1

NoClassDefFoundError occurs when your jars are missing. The json jar should either be provided explicitly or as a shared library in your server. Once the jar is added, your issue should be resolved.


Note: You should mention a lot more details like

  • how are you running the code (as a standalone or on a server)
  • if you are running on a server, which is the server, what is the java runtime
  • also, format the code as

String jsonString = ""; //all your code snippet

phoenixSid
  • 447
  • 1
  • 8
  • 22
  • thanks for answer, i use 'json-20170516.jar' into spring-mvc project and i run this project in tomcat server. but i get above error. – yaghob abbasi Jun 01 '17 at 10:57