Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 497
Freddy Boucher Avatar asked Apr 17 '18 06:04

Freddy Boucher


3 Answers

I got same error, solved it by excluding the jar in pom.xml

<dependencies>
          <dependency>
          [...]
            <exclusions>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclusion>
            </exclusions>
  </dependency>
        </dependencies>
like image 172
Subha Chandra Avatar answered Oct 20 '22 01:10

Subha Chandra


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.

like image 33
Didier Avatar answered Oct 19 '22 23:10

Didier


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!

like image 28
Freddy Boucher Avatar answered Oct 20 '22 00:10

Freddy Boucher