升级Jersey版本

时间:2017-08-26 09:46:00

标签: java google-app-engine jersey-2.0

最近不得不将Jersey的版本从2.5.1(后面解释的原因)升级到2.7并且自升级以来,每次我将代码上传到服务器时,随机API调用都会因以下堆栈跟踪而失败:

org.glassfish.jersey.internal.Errors logErrors: The following warnings have been detected: WARNING: HK2 service reification failed for [com.example.rest.LeaderboardApi] with an exception:
MultiException stack 1 of 2
java.lang.NullPointerException
        at org.jvnet.hk2.internal.Utilities.hasInjectAnnotation(Utilities.java:1484)
        at org.jvnet.hk2.internal.Utilities.findInitializerMethods(Utilities.java:1425)
        at org.jvnet.hk2.internal.DefaultClassAnalyzer.getInitializerMethods(DefaultClassAnalyzer.java:102)
        at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getInitializerMethods(JerseyClassAnalyzer.java:239)
        at org.jvnet.hk2.internal.Utilities.getInitMethods(Utilities.java:243)
        at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:163)
        at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:200)
        at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:649)
        at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:604)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:405)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2046)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.access$700(ServiceLocatorImpl.java:116)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$6.compute(ServiceLocatorImpl.java:1011)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$6.compute(ServiceLocatorImpl.java:1006)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:115)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:111)
        at java.util.concurrent.FutureTask.run(FutureTask.java:260)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture.run(LRUHybridCache.java:173)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(LRUHybridCache.java:292)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetDescriptor(ServiceLocatorImpl.java:1093)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:616)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)
        at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173)
        at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
        at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94)
        at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63)
        at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:252)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1023)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:535)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:483)
        at com.example.config.JerseyFilter.doFilter(JerseyFilter.java:27)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:420)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
        at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
        at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
        at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:657)
        at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:619)
        at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:589)
        at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
        at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
        at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
        at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
        at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
        at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
        at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:263)
        at java.lang.Thread.run(Thread.java:745)

MultiException stack 2 of 2
java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
        implementation=com.example.rest.LeaderboardApi
        contracts={com.example.rest.LeaderboardApi}
        scope=org.glassfish.jersey.process.internal.RequestScoped
        qualifiers={}
        descriptorType=CLASS
        descriptorVisibility=NORMAL
        metadata=
        rank=0
        loader=null
        proxiable=null
        proxyForSameScope=null
        analysisName=null
        id=156
        locatorId=0
        identityHashCode=1367521629
        reified=false)
        at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:615)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:405)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2046)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.access$700(ServiceLocatorImpl.java:116)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$6.compute(ServiceLocatorImpl.java:1011)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$6.compute(ServiceLocatorImpl.java:1006)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:115)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:111)
        at java.util.concurrent.FutureTask.run(FutureTask.java:260)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture.run(LRUHybridCache.java:173)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(LRUHybridCache.java:292)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetDescriptor(ServiceLocatorImpl.java:1093)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:616)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)
        at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173)
        at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
        at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
        at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94)
        at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63)
        at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:252)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1023)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:535)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:483)
        at com.example.config.JerseyFilter.doFilter(JerseyFilter.java:27)
        at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:420)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
        at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
        at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
        at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:657)
        at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:619)
        at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:589)
        at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
        at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
        at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
        at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
        at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
        at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
        at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:263)
        at java.lang.Thread.run(Thread.java:745)

每次我进行干净的构建并重新上传时,一组新方法会在没有任何代码更改的情况下开始失败(以前失败的方法开始工作)!

尝试2.7之后,我切换到了2.25.1并开启了另一个蠕虫病毒,所以我尝试了2.5.2(而不是原来的2.5.1)并且它遇到了与2.5.1相同的问题。我切换到2.8,它有与2.7相同的随机问题。

当前状态是版本2.7或2.8,REST API方法的一个小的(至少看似)随机子集失败,消息类似于上面的消息。

我想找出原因,并解决它。

切换泽西版本时遵循的方法

我会清除/WEB-INF/lib文件夹,将jersey.version中的pom.xml变量更改为新版本。然后,Eclipse将获取所有必需的库并重新构建代码。运行mvn appengine:update会重新填充/WEB-INF/lib文件夹并将所有内容打包。

有几次我做了一个干净的(完整)版本,以确保不同版本的文物不会混合。

从2.5.1升级的原因

必须添加一个方法(带有以下签名):

public Response importChildren(@Context ContainerRequestContext reqCtx,
        @PathParam(ID) String id, @FormDataParam("file") InputStream csvStream,
        @FormDataParam("test") String testStr)

将获取InputStream CSV文件并对其进行处理。因此必须添加jersey-media-multipart。与版本2.5.x一起使用(未尝试使用2.6),这会开始出错,因为它会尝试将InputStream写入临时文件(Google App Engine(标准)中禁止写入磁盘,是我正在使用的。)

对于版本> = 2.7,可以通过添加内容为jersey-multipart-config.properties

的文件jersey.config.multipart.bufferThreshold = -1来避免编写临时文件的趋势

绝望的解决方法

如果没有别的办法,我可以将CSV处理代码从Jersey介导的方法中移出一个简单的servlet。然后我不需要jersey-media-multipart并且可以回到使用版本2.5.1,其中所有代码都可靠地工作。

3 个答案:

答案 0 :(得分:6)

这一个

java.lang.NullPointerException
    at org.jvnet.hk2.internal.Utilities.hasInjectAnnotation(Utilities.java:1484)

是Jersey与特定底层HK2内核版本之间的known bug互操作,它与Jersey 2.7一起作为传递依赖

  

我们已经在2.9-SNAPSHOT中切换到HK2 2.3.0-b05。在我们发布2.9后,问题应该消失。

看起来修复该错误的最近的泽西岛版本是2.9。但是,如果您希望继续使用2.7,请找到以下解决方法。

强制通过Maven使用hk2-api 2.3.0-b05版本:

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-common</artifactId>
    <version>2.7</version>
    <exclusions>
        <exclusion>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-api</artifactId>
            <!-- this is to exclude 2.2.0 version -->
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.glassfish.hk2</groupId>
    <artifactId>hk2-api</artifactId>
    <version>2.3.0-b05</version>
</dependency>

您的pom.xml中的某些其他Jersey工件可能需要排除练习,只需相应地检查mvn dependency:tree ...

答案 1 :(得分:3)

完整和完整的解决方案

answer @Kostiantyn让我走上了正确的道路,尽管我必须做一些小改动才能让它发挥作用。因此,其他人可以避免我不得不面对的浪费时间,我将在下面提供完整的解决方案。

正如@Kostiantyn指出的那样,我需要升级到Jersey 2.9以摆脱Jersey和HK2之间的互操作错误。但是,当我切换到2.9时,我开始在所有POST / PUT方法上得到以下错误(所有这些@Consumes(MediaType.APPLICATION_JSON)

org.glassfish.jersey.message.internal.ReaderInterceptorExecu‌​tor$TerminalReaderIn‌​terceptor aroundReadFrom:
  MessageBodyReader not found for media type=application/json, type=class com.example.json.StarDto,
    genericType=class com.example.json.StarDto

这是一个很大的问题,为了解决这个问题,我添加了以下依赖项(基于@Kostiantyn的建议):

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>${jersey.version}</version>
        <scope>runtime</scope>
    </dependency>

使用这个新添加的依赖项测试后,旧的错误消失了,而我开始在我的POST方法上获得以下内容(没有测试PUT方法):

org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError:
  com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase.<init>(Lc‌​om/fasterxml/jackson‌​/databind/cfg/Mapper‌​Config;

在尝试了很多不同的事情后,我终于意识到jersey-media-json-jackson正在引入jackson-jaxrs-base-2.3.2.jar,这与jackson-jaxrs-base- 2.7.1 相矛盾。 jar(这是我需要的版本)。因此,添加jersey-media-json-jackson以下排除最终解决了我的所有问题:

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>${jersey.version}</version>
        <scope>runtime</scope>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.jaxrs</groupId>
                <artifactId>jackson-jaxrs-base</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

答案 2 :(得分:0)

尝试将我的应用程序部署到weblogic服务器时遇到完全相同的问题。

重新启动weblogic托管服务器对我来说是有效的

要停止:

通过在Web浏览器的URL行中键入http://[host name]:[port] /控制台来启动WebLogic Server管理控制台。

在“域结构”下,单击“环境”>“服务器”。

在右窗格中,单击“控制”选项卡。

选择要停止的受管服务器。

单击要停止的受管服务器下方的“关机”按钮。

选择“工作完成时”以正常关闭服务器,或选择“立即强制关机”以立即停止服务器而无需完成正在进行的任务。

在“服务器生命周期助手”窗格上,单击“是”以完成关闭。

开始:

确保WebLogic Server和节点管理器正在运行。

通过在Web浏览器的URL行中键入http://[host name]:[port] /控制台来启动WebLogic Server管理控制台。

在“域结构”下,单击“环境”>“服务器”。

在右窗格中,单击“控制”选项卡。

选择要启动的受管服务器。

单击要启动的受管服务器下方的“开始”按钮。