Today, I use JSONObject when doing web projects, using the lib of struts2 automatically imported by MyEclipse, which comes with json-lib-2.1-jdk15.jar.
The net.sf.json.JSONObject package has been imported in the action of struts2. I found that when using JSONObject jsonObject = new JSONObject(), MyEclipse did not report an error, but when it came to JSONObject jsonObject = new JSONObject(), it could not execute!
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.reflect.InvocationTargetException sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …………………… org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
mapsns.action.Login.login(Login.java:34)
……………………
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
……………………
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.
Apache Tomcat/7.0.30
It found java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher, obviously the corresponding class was not found. It turns out that in addition to importing the json-lib-2.1-jdk15.jar package, several other dependent packages must be imported: commons-beanutils.jar, commons-httpclient.jar, commons-lang.jar, ezmorph.jar, morph- 1.0.1.jar
After importing these dependency packages, there will be no more errors!
http://blog.csdn.net/weizi4332/article/details/9302229