![](/img/trans.png)
[英]Exception in thread “main” java.lang.NoSuchFieldError: INSTANCE in AWS SNS
[英]Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
我正在嘗試使用 HTTPClient 編寫一個簡單的 WebService 測試。 我已經加載了所有的罐子,但收到了上述錯誤消息。
為什么我會收到此錯誤消息?
這是代碼:
package HTTPClientTest;
import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.Assert;
public class RESTTester {
public static void main (String args[]) {
String restURL_XML = "http://parabank.parasoft.com/parabank/services/bank/customers/12212/";
try {
testStatusCode(restURL_XML);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void testStatusCode(String restURL) throws ClientProtocolException, IOException {
HttpUriRequest request = new HttpGet(restURL);
HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
Assert.assertEquals(httpResponse.getStatusLine().getStatusCode(),HttpStatus.SC_OK);
}
}
下面是錯誤堆棧跟蹤,
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966)
at HTTPClientTest.RESTTester.testStatusCode(RESTTester.java:37)
at HTTPClientTest.RESTTester.main(RESTTester.java:22)
我收到上述錯誤是因為我的項目中有多個舊版本的 HTTPClient。 我刪除了舊版本的 HTTPClient,現在錯誤消息消失了。
通過分析你的堆棧跟蹤,我發現你的程序寫得很好。 似乎 apache HTTP API 編譯錯誤。 也許包org.apache.http.impl.client
是針對與您使用的不同版本的org.apache.http.conn.ssl
編譯的? 將這兩個軟件包升級到最新版本並重試。 將其報告給 HTTPClient 錯誤跟蹤器。
我ve come across this error(java.lang.NoSuchFieldError: INSTANCE) several times. With different reasons here it is INSTANCE. This error is conveying about the mismatch between the aws-java-sdk-core library and one of the service-specific SDK
ve come across this error(java.lang.NoSuchFieldError: INSTANCE) several times. With different reasons here it is INSTANCE. This error is conveying about the mismatch between the aws-java-sdk-core library and one of the service-specific SDK
ve come across this error(java.lang.NoSuchFieldError: INSTANCE) several times. With different reasons here it is INSTANCE. This error is conveying about the mismatch between the aws-java-sdk-core library and one of the service-specific SDK
s aws-sdk-s3 或 aws-java-sdk-sqs 之一不匹配。
我在將 aws-java-sdk-core(1.11.289) 與 aws-sdk-s3(1.11.428) 一起使用時遇到了這個錯誤。 通過將以下 aws-java-sdk-core(1.11.289) 與 aws-sdk-s3(1.11.186) 一起使用來修復它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.