[英]Rest Easy Client 3.0.10 with tomcat 8 java.lang.NoSuchMethodError: javax.ws.rs.core.Response.close()V
I am developing rest service using ReastEasy 3.0.10 API with tomcat 8 and jAVA 8. My code is working fine on window machine but when I deployed WAR file on Linux machine, It gives error org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: javax.ws.rs.core.Response.close()V
I am developing rest service using ReastEasy 3.0.10 API with tomcat 8 and jAVA 8. My code is working fine on window machine but when I deployed WAR file on Linux machine, It gives error
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: javax.ws.rs.core.Response.close()V
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: javax.ws.rs.core.Response.close()V
The no of jar files are same as it is on local. jar 个文件的编号与本地相同。 I am having two jar files
javax.ws.rs-api-2.0.1
and jaxrs-api-3.0.10.Final
in my lib folder.我的 lib 文件夹中有两个 jar 文件
javax.ws.rs-api-2.0.1
和jaxrs-api-3.0.10.Final
。 Both are having Response class and close method.两者都有响应 class 和关闭方法。 But Still it is giving error on Linux server.
但它仍然在 Linux 服务器上出错。 Any suggestion?
有什么建议吗?
The client code is客户端代码是
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();
}
Also I have noticed one thing, It calls the rest service and print data which rest is returning but After that it prints Internal Server Error 500 in log before printing above mentioned error.我还注意到一件事,它调用 rest 服务并打印 rest 返回的数据,但之后它在打印上述错误之前在日志中打印内部服务器错误 500。
Ok. 好。 After investing one day finally I found that this error comes when some other jar having same class with same package structure.
经过一天的投资,我最终发现当其他罐子具有相同的类和相同的包结构时,就会出现此错误。 I used a tool JARMINATOR to scan all of my jar files.
我使用工具JARMINATOR扫描了我所有的jar文件。 Now I have fixed this issue but still it is a question why window machine was not loading that jar but linux machine was loading into Linux machine.
现在我已经解决了这个问题,但是仍然是一个问题,为什么窗口计算机没有加载该jar,而Linux计算机却加载到了Linux计算机中。
I have resolved it by excluding the below.我已经通过排除以下内容解决了它。
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.