不能使用jax-rs jersey2的路径参数或查询参数

时间:2016-08-19 00:26:04

标签: jersey jetty guice

我被困在这里。我使用guice作为注入器在jersey2的简单jetty服务器中工具,我可以从API调用返回数据没问题。但是,如果我尝试接受查询参数或路径参数,我会得到以下神秘堆栈跟踪

2016-08-18 17:21:28,611 [qtp854640632-20] WARN  org.eclipse.jetty.server.HttpChannel - /api/mining/listGroups/1
javax.servlet.ServletException: A MultiException has 2 exceptions.  They are:
1. java.lang.IllegalArgumentException
2. java.lang.IllegalStateException: Unable to perform operation: method inject on com.data.services.server.rest.api.TestResource

    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489) ~[jersey-container-servlet-core-2.23.2.jar:na]
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) ~[jersey-container-servlet-core-2.23.2.jar:na]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) ~[jersey-container-servlet-core-2.23.2.jar:na]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) ~[jersey-container-servlet-core-2.23.2.jar:na]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) ~[jersey-container-servlet-core-2.23.2.jar:na]
    at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:287) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:277) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:182) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:119) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:133) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:130) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:203) ~[guice-servlet-4.0.jar:na]
    at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:130) ~[guice-servlet-4.0.jar:na]
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) ~[jetty-servlet-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) ~[jetty-servlet-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) ~[jetty-servlet-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.Server.handle(Server.java:499) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) ~[jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.13.v20150730.jar:9.2.13.v20150730]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
Caused by: org.glassfish.hk2.api.MultiException: A MultiException has 2 exceptions.  They are:
1. java.lang.IllegalArgumentException
2. java.lang.IllegalStateException: Unable to perform operation: method inject on com.services.server.rest.api.TestResource

我的方法看起来像这样

@GET
@Path("test")
def test(@QueryParam("foo") foo: String): String = foo

我知道它不是scala问题,因为我在另一个应用程序中使用了带有scala的dropwizard,但这次我似乎无法弄清楚我甚至想要解决这个问题。我已经证实,jersey / jetty依赖项都是相同的主要版本,并且没有任何1.x绑定进入

0 个答案:

没有答案