网上很多人提到war包部署出现如下错误问题:
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/catering/cater_chain at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1360) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1354) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1008) at com.test.TestJson.sendRequest(TestJson.java:177) at com.test.TestJson.main(TestJson.java:148) Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/catering/cater_chain at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1305) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373) at com.test.TestJson.sendRequest(TestJson.java:176) ... 1 more |
在我项目中也遇到同样的问题。(服务端与客户端以接口数据流的形式交互(json))
部署描述 | 异常情况 | |
1.通过MyEclipse部署到jetty-6.1.14 | 接口访问正常 | IE访问正常 |
2.通过war部署到jetty-6.1.14 | 接口访问正常 | IE访问正常 |
3.通过MyEclipse部署到apache-tomcat-7.0.34 | 接口访问正常 | IE访问正常 |
4.通过war部署到apache-tomcat-7.0.34 | 接口访问异常 | IE访问正常 |
解决方法: 1. 服务端使用response.getWriter().print("message");可解决。 我之前使用的模式是: client(send json[IO])--> (get json[IO])server(send json[request])--> (get json[request])view(send view_json[IO])--> client 2. 在tomcat的F:\Program Files\apache-tomcat-7.0.34\lib目录下添加一个jar包:javax.servlet.jsp.jstl.jar可解决。 |