Solution to the org. apache. catalina. core. StandardWrapperValve invoke error in JSONArray (). fromObject (); standardwrappervalve
Servlet:
1 public void service (HttpServletRequest request, HttpServletResponse response) 2 throws ServletException, IOException {3 4 response. setContentType ("text/html"); 5 response. setCharacterEncoding ("UTF-8"); 6 7 IBllFrame interfaceOfBllFrame = new BllFrame (); 8 JSONArray json = null; 9 10 List <HashMap <String, Object> result = interfaceOfBllFrame. getStationPlace (); 11 System. out. println ("GetStationPlace:" + result. get (1 ). toString (); 12 try {13 System. out. println ("haha begin:" + json); 14 15 json = newJSONArray (). fromObject(Result );// The above error occurs in this sentence16 System. out. println ("haha success:" + json); 17} 18 catch (Exception e) {19 e. printStackTrace (); 20} 21 22 System. out. println ("Servlet --- StationPlace" + json); 23 PrintWriter out = response. getWriter (); 24 out. println (json); 25 out. flush (); 26 out. close (); 27}
The output result in the controller is as follows:
The following is the information:
GetStationPlace: {StationId = 10002, Stationlon = 29.90592, Stationlat = 121.525976}
Haha begin: null
February 29 10:37:46 AMOrg. apache. catalina. core. StandardWrapperValve invoke
Severe: Servlet. service () for servlet [GetStationPlaceServlet] in context with path [/BicycleDataSystem] threw exception [Servlet execution threw an exception] with root cause
Java. lang. ClassNotFoundException: net. sf. json. JSONArray
At org. apache. catalina. loader. WebappClassLoader. loadClass (WebappClassLoader. java: 1722)
At org. apache. catalina. loader. WebappClassLoader. loadClass (WebappClassLoader. java: 1573)
The original commons-beanutils.jar, commons-collections.jar, commons-lang.jar, commons-logging.jar, ezmorph. jar, json-lib.jar package in lib-"json folder is as follows:
Later commons-beanutils.jar, commons-collections.jar, commons-lang.jar, commons-logging.jar, ezmorph. jar, json-lib.jar put directly under the lib folder, as follows:
Note: that is to say commons-beanutils.jar, commons-collections.jar, commons-lang.jar, commons-logging.jar, ezmorph. jar, json-lib.jar these packagesBe sure to directly put it in the lib folderOtherwiseOrg. apache. catalina. core. StandardWrapperValve invokeError.
JSONArray (). fromObject requires the following jar package:Commons-beanutils.jar, commons-collections.jar, commons-lang.jar, commons-logging.jar, ezmorph. jar, json-lib.jar
: Http://pan.baidu.com/s/1pJUmBQN
References: http://greenboy1.iteye.com/blog/1046125