基本上,我使用Java中的mailgun API发送一封简单的电子邮件,但是在将所需的库导入到我的项目并调用该函数之后,我收到以下异常:
java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:53)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:57)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:47)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:83)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:96)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:105)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:63)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:600)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:179)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:163)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:154)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:130)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:121)
at com.mashape.unirest.http.options.Options.refresh(Options.java:72)
at com.mashape.unirest.http.options.Options.<clinit>(Options.java:46)
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at duck.reg.pack.getstkcntents.sendSimpleMessage(getstkcntents.java:159)
at duck.reg.pack.getstkcntents.doPost(getstkcntents.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:501)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
公共静态JsonNode sendSimpleMessage()抛出UnirestException {
HttpResponse<JsonNode> request = Unirest.post("https://api.mailgun.net/v3/" + "domainname" + "/messages")
.basicAuth("api", "api-key")
.queryString("from", "Excited User <email@domain.do.com>")
.queryString("to", "to@someone.com")
.queryString("subject", "hello")
.queryString("text", "testing")
.asJson();
return request.getBody();
}
我的图书馆清单:
activation-1.1.1.jar
activation.jar
annotations-api.jar
antisamy-1.5.1.jar
apache-xml-xerces.jar
batik-all-1.7.jar
batik-css-1.7.jar
catalina-ant.jar
catalina-ha.jar
catalina.jar
catalina-storeconfig.jar
catalina-tribes.jar
commons-codec-1.10.jar
commons-fileupload-1.3.jar
commons-io-2.5.jar
commons-io-2.5-javadoc.jar
commons-logging-1.1.1.jar
commons-logging-1.1.1-sources.jar
commons-logging-1.2.jar
cos-multipart.jar
ecj-4.5.1.jar
ecj-4.6.1.jar
el-api.jar
fluent-hc-4.5.6.jar
google-api-client-1.23.0.jar
google-api-client-1.23.0.jar.properties
google-api-client-1.23.0-sources.jar
google-api-client-android-1.23.0.jar
google-api-client-android-1.23.0.jar.properties
google-api-client-android-1.23.0-sources.jar
google-api-client-appengine-1.23.0.jar
google-api-client-appengine-1.23.0-sources.jar
google-api-client-gson-1.23.0.jar
google-api-client-gson-1.23.0-sources.jar
google-api-client-jackson2-1.23.0.jar
google-api-client-jackson2-1.23.0-sources.jar
google-api-client-java6-1.23.0.jar
google-api-client-java6-1.23.0-sources.jar
google-api-client-servlet-1.23.0.jar
google-api-client-servlet-1.23.0-sources.jar
google-api-services-youtube-v3-rev187-1.23.0.jar
google-api-services-youtube-v3-rev187-1.23.0-javadoc.jar
google-api-services-youtube-v3-rev187-1.23.0-sources.jar
google-http-client-1.23.0.jar
google-http-client-1.23.0.jar.properties
google-http-client-1.23.0-sources.jar
google-http-client-android-1.23.0.jar
google-http-client-android-1.23.0.jar.properties
google-http-client-android-1.23.0-sources.jar
google-http-client-appengine-1.23.0.jar
google-http-client-appengine-1.23.0-sources.jar
google-http-client-gson-1.23.0.jar
google-http-client-gson-1.23.0.jar.properties
google-http-client-gson-1.23.0-sources.jar
google-http-client-jackson2-1.23.0.jar
google-http-client-jackson2-1.23.0.jar.properties
google-http-client-jackson2-1.23.0-sources.jar
google-http-client-jdo-1.23.0.jar
google-http-client-jdo-1.23.0.jar.properties
google-http-client-jdo-1.23.0-sources.jar
google-oauth-client-1.23.0.jar
google-oauth-client-1.23.0.jar.properties
google-oauth-client-1.23.0-sources.jar
google-oauth-client-appengine-1.23.0.jar
google-oauth-client-appengine-1.23.0-sources.jar
google-oauth-client-java6-1.23.0.jar
google-oauth-client-java6-1.23.0-sources.jar
google-oauth-client-jetty-1.23.0.jar
google-oauth-client-jetty-1.23.0-sources.jar
google-oauth-client-servlet-1.23.0.jar
google-oauth-client-servlet-1.23.0-sources.jar
gson-2.1.jar
gson-2.1.jar.properties
gson-2.1-sources.jar
gson-2.7.jar
gson-2.7-javadoc.jar
gson-2.7-sources.jar
guava-19.0.jar
httpasyncclient-4.1.4.jar
httpasyncclient-cache-4.1.4.jar
httpclient-4.0.1.jar
httpclient-4.0.1-sources.jar
httpclient-4.5.6.jar
httpclient-cache-4.5.6.jar
httpclient-win-4.5.6.jar
httpcore-4.0.1.jar
httpcore-4.0.1-sources.jar
httpcore-4.4.10.jar
httpcore-nio-4.4.10.jar
httpmime-4.5.6.jar
jackson-core-2.1.3.jar
jackson-core-2.1.3.jar.properties
jackson-core-2.1.3-sources.jar
jasper-el.jar
jasper.jar
jaspic-api.jar
java-json.jar
javax.ejb.jar
jdo2-api-2.3-eb.jar
jdo2-api-2.3-eb-sources.jar
jetty-6.1.26.jar
jetty-6.1.26-sources.jar
jetty-util-6.1.26.jar
jetty-util-6.1.26-sources.jar
jna-4.4.0.jar
jna-platform-4.4.0.jar
jsp-api.jar
jsr305-1.3.9.jar
mail-1.4.1.jar
mail.jar
multipartrequest.jar
mysql-connector-java-5.1.39-bin.jar
nekohtml.jar
org.json.jar
org.springframework.webmvc.jar
servlet-api.jar
spring-aop-4.3.3.RELEASE.jar
spring-aop-4.3.3.RELEASE-javadoc.jar
spring-aop-4.3.3.RELEASE-sources.jar
spring-aspects-4.3.3.RELEASE.jar
spring-aspects-4.3.3.RELEASE-javadoc.jar
spring-aspects-4.3.3.RELEASE-sources.jar
spring-beans-4.3.3.RELEASE.jar
spring-beans-4.3.3.RELEASE-javadoc.jar
spring-beans-4.3.3.RELEASE-sources.jar
spring-context-4.3.3.RELEASE.jar
spring-context-4.3.3.RELEASE-javadoc.jar
spring-context-4.3.3.RELEASE-sources.jar
spring-context-support-4.3.3.RELEASE.jar
spring-context-support-4.3.3.RELEASE-javadoc.jar
spring-context-support-4.3.3.RELEASE-sources.jar
spring-core-4.3.3.RELEASE.jar
spring-core-4.3.3.RELEASE-javadoc.jar
spring-core-4.3.3.RELEASE-sources.jar
spring-expression-4.3.3.RELEASE.jar
spring-expression-4.3.3.RELEASE-javadoc.jar
spring-expression-4.3.3.RELEASE-sources.jar
spring-instrument-4.3.3.RELEASE.jar
spring-instrument-4.3.3.RELEASE-javadoc.jar
spring-instrument-4.3.3.RELEASE-sources.jar
spring-instrument-tomcat-4.3.3.RELEASE.jar
spring-instrument-tomcat-4.3.3.RELEASE-javadoc.jar
spring-instrument-tomcat-4.3.3.RELEASE-sources.jar
spring-jdbc-4.3.3.RELEASE.jar
spring-jdbc-4.3.3.RELEASE-javadoc.jar
spring-jdbc-4.3.3.RELEASE-sources.jar
spring-jms-4.3.3.RELEASE.jar
spring-jms-4.3.3.RELEASE-javadoc.jar
spring-jms-4.3.3.RELEASE-sources.jar
spring-messaging-4.3.3.RELEASE.jar
spring-messaging-4.3.3.RELEASE-javadoc.jar
spring-messaging-4.3.3.RELEASE-sources.jar
spring-orm-4.3.3.RELEASE.jar
spring-orm-4.3.3.RELEASE-javadoc.jar
spring-orm-4.3.3.RELEASE-sources.jar
spring-oxm-4.3.3.RELEASE.jar
spring-oxm-4.3.3.RELEASE-javadoc.jar
spring-oxm-4.3.3.RELEASE-sources.jar
spring-test-4.3.3.RELEASE.jar
spring-test-4.3.3.RELEASE-javadoc.jar
spring-test-4.3.3.RELEASE-sources.jar
spring-tx-4.3.3.RELEASE.jar
spring-tx-4.3.3.RELEASE-javadoc.jar
spring-tx-4.3.3.RELEASE-sources.jar
spring-web-4.3.3.RELEASE.jar
spring-web-4.3.3.RELEASE-javadoc.jar
spring-web-4.3.3.RELEASE-sources.jar
spring-webmvc-4.3.3.RELEASE.jar
spring-webmvc-4.3.3.RELEASE-javadoc.jar
spring-webmvc-4.3.3.RELEASE-sources.jar
spring-webmvc-portlet-4.3.3.RELEASE.jar
spring-webmvc-portlet-4.3.3.RELEASE-javadoc.jar
spring-webmvc-portlet-4.3.3.RELEASE-sources.jar
spring-websocket-4.3.3.RELEASE.jar
spring-websocket-4.3.3.RELEASE-javadoc.jar
spring-websocket-4.3.3.RELEASE-sources.jar
tomcat-api.jar
tomcat-coyote.jar
tomcat-dbcp.jar
tomcat-i18n-es.jar
tomcat-i18n-fr.jar
tomcat-i18n-ja.jar
tomcat-jdbc.jar
tomcat-jni.jar
tomcat-util.jar
tomcat-util-scan.jar
tomcat-websocket.jar
transaction-api-1.1.jar
transaction-api-1.1-sources.jar
unirest-java-1.4.9.jar
websocket-api.jar
xercesImpl-2.8.1.jar
xuggle-xuggler-5.4.jar
xuggle-xuggler-arch-i386-xuggle-darwin11.jar
xuggle-xuggler-arch-i686-pc-linux-gnu.jar
xuggle-xuggler-arch-i686-w64-mingw32.jar
xuggle-xuggler-arch-x86_64-pc-linux-gnu.jar
xuggle-xuggler-arch-x86_64-w64-mingw32.jar
xuggle-xuggler-arch-x86_64-w64-mingw32_LIFERAY-PATCHED-1.jar
xuggle-xuggler-arch-x86_64-xuggle-darwin11.jar
xuggle-xuggler-noarch-5.4.jar
xuggle-xuggler-noarch-5.4.jar.zip
commons-logging-1.1.1.jar
commons-logging-1.1.1-sources.jar
google-api-client-1.23.0.jar
google-api-client-1.23.0-sources.jar
google-api-client-android-1.23.0.jar
google-api-client-android-1.23.0-sources.jar
google-api-client-appengine-1.23.0.jar
google-api-client-appengine-1.23.0-sources.jar
google-api-client-gson-1.23.0.jar
google-api-client-gson-1.23.0-sources.jar
google-api-client-jackson2-1.23.0.jar
google-api-client-jackson2-1.23.0-sources.jar
google-api-client-java6-1.23.0.jar
google-api-client-java6-1.23.0-sources.jar
google-api-client-servlet-1.23.0.jar
google-api-client-servlet-1.23.0-sources.jar
google-api-services-youtube-v3-rev187-1.23.0.jar
google-api-services-youtube-v3-rev187-1.23.0-javadoc.jar
google-api-services-youtube-v3-rev187-1.23.0-sources.jar
google-collections-0.9.jar
google-http-client-1.23.0.jar
google-http-client-1.23.0-sources.jar
google-http-client-android-1.23.0.jar
google-http-client-android-1.23.0-sources.jar
google-http-client-appengine-1.23.0.jar
google-http-client-appengine-1.23.0-sources.jar
google-http-client-gson-1.23.0.jar
google-http-client-gson-1.23.0-sources.jar
google-http-client-jackson2-1.23.0.jar
google-http-client-jackson2-1.23.0-sources.jar
google-http-client-jdo-1.23.0.jar
google-http-client-jdo-1.23.0-sources.jar
google-oauth-client-1.23.0.jar
google-oauth-client-1.23.0-sources.jar
google-oauth-client-appengine-1.23.0.jar
google-oauth-client-appengine-1.23.0-sources.jar
google-oauth-client-java6-1.23.0.jar
google-oauth-client-java6-1.23.0-sources.jar
google-oauth-client-jetty-1.23.0.jar
google-oauth-client-jetty-1.23.0-sources.jar
google-oauth-client-servlet-1.23.0.jar
google-oauth-client-servlet-1.23.0-sources.jar
gson-2.1.jar
gson-2.1-sources.jar
httpclient-4.0.1.jar
httpclient-4.0.1-sources.jar
httpcore-4.0.1.jar
httpcore-4.0.1-sources.jar
jackson-core-2.1.3.jar
jackson-core-2.1.3-sources.jar
jdo2-api-2.3-eb.jar
jdo2-api-2.3-eb-sources.jar
jetty-6.1.26.jar
jetty-6.1.26-sources.jar
jetty-util-6.1.26.jar
jetty-util-6.1.26-sources.jar
jsr305-1.3.9.jar
transaction-api-1.1.jar
transaction-api-1.1-sources.jar
导入后出现异常:
org.json.jar
commons-codec-1.10.jar
commons-logging-1.2.jar
httpasynclient-4.1.4.jar
httpasyncclient-cache-4.1.4.jar
httpclient-4.5.6.jar
httpclient-cache-4.5.6.jar
httpcore-4.4.10.jar
httpcore-4.4.10.jar
httpcore-nio.4.4.10.jar
commons-codec-1.10.jar
commons-logging-1.2.jar
fluent-hc-4.5.6.jar
httpclient-4.5.6.jar
httpclient-cache-4.5.6.jar
httpclient-win-4.5.6.jar
httpcore-4.4.10.jar
httpmime-4.5.6.jar
jna-4.4.0.jar
jna-platform-4.4.0.jar
unirest-java-1.4.9.jar
尽管我搜索了原因,但发现可能由于库的不兼容而发生,但是很遗憾,我无法在此处找到不兼容的内容。
谢谢!