我正在開發Rest服務,使用Recat Easy 3.0.10 API與tomcat 8和jAVA 8。我的代碼在窗口機器上工作正常,但是當我在Linux機器上部署WAR文件時,它給出錯誤org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: javax.ws.rs.core.Response.close()V
Rest Easy Client 3.0.10 with tomcat 8 java.lang.NoSuchMethodError:javax.ws.rs.core.Response.close()V
jar文件的no與本地相同。我在我的lib文件夾中有兩個jar文件javax.ws.rs-api-2.0.1
和jaxrs-api-3.0.10.Final
。兩者都有Response類和close方法。但它仍然在Linux服務器上發生錯誤。任何建議?
客戶端代碼是
try {
Client client = ClientBuilder.newClient();
String targetUrl = "http://xxx.xxx.xxx.xxx:xxxx/appname/rest/resturl"
WebTarget target = client.target(targetUrl);
response = target.request(MediaType.APPLICATION_JSON).header("AUTHENTICATED", true)
.post(Entity.entity(RestUtil.convertObjectToJSONString(object), MediaType.APPLICATION_JSON));
responseString = response.readEntity(String.class);
}catch(Exception e){
e.printStackTrace();
} finally {
response.close();
}
而且我注意到一兩件事,它要求其休息還是返回了REST服務和打印的數據,但在此之後它打印內部服務器錯誤500在日誌上述錯誤打印前。