0
我使用org.apache.http.client从Tomcat 7调用POST。 相同的代码在我的开发机器上工作,但失败我的服务器。HttpClient没有在Tomcat上工作,NoSuchMethodError org/apache/http/entity/ContentType
我似乎是一个类加载器的问题,但我双重检查了所有的罐子,并且他们的lib目录中有相同的罐子。
java.lang.NoSuchMethodError: org.apache.http.entity.StringEntity.<init>(Ljava/lang/String;Lorg/apache/http/entity/ContentType;)V
org.apache.http.client.entity.UrlEncodedFormEntity.<init>(UrlEncodedFormEntity.java:61)
org.botlibre.util.Utils.httpPOST(Utils.java:424)
我倾倒了使用的罐子,并且两个tomcat都使用相同的httpclient-4.2.5.jar和http罐子。
我的开发机具有的Tomcat 7.0.50和服务器7.0.68
CodeSource src = StringEntity.class.getProtectionDomain().getCodeSource();
if (src != null) {
System.out.println(src.getLocation());
}
Class klass = StringEntity.class;
URL location = klass.getResource('/' + klass.getName().replace('.', '/') + ".class");
System.out.println(location);
听起来像一个依赖性的冲突,也许你有不同的版本重复的罐子,确保您所有的HttpClient库都来自同一版本,并且没有重复。 – vzamanillo