Resteasy 3.5.0.Final on App Engine standard env - NoSuchFieldError SERVER_SENT_EVENTS_TYPE

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

I have a pretty basic Java8 application using Resteasy 3.1.4.Final deployed in App Engine standard env.

But when I upgrade Resteasy to 3.5.0.Final;

  • All good in my local env
  • I get the following Stacktrace when deployed:

Uncaught exception from servlet java.lang.NoSuchFieldError: SERVER_SENT_EVENTS_TYPE at org.jboss.resteasy.core.ResourceMethodInvoker.isSseResourceMethod(ResourceMethodInvoker.java:162) at org.jboss.resteasy.core.ResourceMethodInvoker.(ResourceMethodInvoker.java:147) at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:345) at org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:272) at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:223) at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:195) at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:181) at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:158) at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:77) at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:496) at org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:279) at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:86) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:119) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:643) at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:422) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1406) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:244) at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:182) at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:97) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:680) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:642) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:612) at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:806) at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:274) at java.lang.Thread.run(Thread.java:745)

So it's seems to be environment related. Any clue to solve it?

Thanks

回答1:

I'm posting @NicoNes's answer I received in Github

Hi @freddyboucher I don't think that this commit is responsible of the NoSuchFieldError you are dealing with. Resteasy 3.1.4.Final is an implementation of the JAX-RS-API 2.0.1 spec whereas 3.5.1.Final is an impl of the JAX-RS-API 2.1 spec. And the missing field you are talking about is coming from the javax.ws.rs.core.MediaType in JAX-RS-API 2.1. So can you please be sure that your runtime execution does not embed the wrong version o the JAX-RS-API ?

Let me know.

-Nicolas

And he was right, I had in my pom.xml:

  <dependencyManagement>       <dependencies>         <dependency>           <groupId>javax.ws.rs</groupId>           <artifactId>javax.ws.rs-api</artifactId>           <version>2.0.1</version>         </dependency>       </dependencies>   </dependencyManagement> 

Upgrading to 2.1, fixed my issue!



回答2:

I had the same problem.

I have solved it by deleting org.jboss.resteasy.jaxrs-api.3.0.12.Final from my pom file.

Hope that will solve your problem.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!