我正在尝试使用wiremock(testCompile' com.github.tomakehurst:wiremock:2.1.4-rc3')来在使用' org.eclipse的webapp中执行JUnit测试.jetty:码头服务器:9.3.6.v20151106'作为一种依赖性。
当我运行Junit测试时,我收到错误并且线程2.1.4-rc3似乎与jetty9不兼容......
[错误:java.lang.NoSuchMethodError:org.eclipse.jetty.server.Request.getUri()Lorg / eclipse / jetty / http / HttpURI;]
完整筹码:
java.lang.NoSuchMethodError: org.eclipse.jetty.server.Request.getUri()Lorg/eclipse/jetty/http/HttpURI;
at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.isBrowserProxyRequest(WireMockHttpServletRequestAdapter.java:219)
at com.github.tomakehurst.wiremock.verification.LoggedRequest.createFrom(LoggedRequest.java:59)
at com.github.tomakehurst.wiremock.http.AdminRequestHandler.handleRequest(AdminRequestHandler.java:40)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:41)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:3)
这是Jetty服务器兼容性问题。
你正在使用Jetty 9.3.6.v20151106,WireMock 2.1.4-rc3依赖于Jetty 9.2.13.v20150730。
此方法已删除,并且在Jetty 9.3.6中的org.eclipse.jetty.server.Request
上不存在。
public org.eclipse.jetty.http.HttpURI getUri();
最简单的解决方案是降级您正在使用的Jetty版本,并使用与WireMock相同的版本。或者,您可以分叉WireMock并升级您正在使用的Jetty版本。听起来不是最佳?已经讨论过重构WireMock以更好地处理这个问题:https://github.com/tomakehurst/wiremock/pull/442