javagoogle-app-enginejerseyobjectifyjsr311

Code works on dev server, fails to start on GAE


Till recently my code had been working fine, on GAE and on dev server. Then recently I uploaded a new version and that doesn't work at all on the server, works just fine on my local machine (dev server). The older version continues to work on the server.

Every time the I hit any URL of the newer version, the following stracktrace is found in the logs:

Uncaught exception from servlet
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:287)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:389)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:206)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:179)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:136)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:468)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
    at java.lang.Thread.run(Thread.java:745)

This is the most relevant dependency that I could find (it's in a utility library that I am using in my project):

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
</dependency>

and true enough, the javax.ws.rs.core.Application class in it doesn't contain a getProperties() method.

Now the question is, why/how is this code working on the dev server?

I haven't made any recent changes that affect this library or even the general layout and working of the code (just added some functionality to existing code), so what is causing this issue?

Was using version 1.9.32 of GAE Java SDK and recently upgraded to 1.9.34 -- problem happened after that (however, switching back to 1.9.32 didn't help). Cloud Platform console indicates SDK version 1.9.35.

In desperation I tried:

Versions from pom.xml:

<commons.codec.version>1.10</commons.codec.version>
<commons.io.version>2.4</commons.io.version>
<commons.lang3.version>3.4</commons.lang3.version>
<commons.validator.version>1.5.0</commons.validator.version>
<freemarker.version>2.3.20</freemarker.version>
<google.http.client.version>1.21.0</google.http.client.version>
<guava.version>19.0</guava.version>
<guice.servlet.version>4.0</guice.servlet.version>
<guice.version>4.0</guice.version>
<jackson.version>2.7.0</jackson.version>
<jersey.version>2.5.1</jersey.version>
<joda.money.version>0.10.0</joda.money.version>
<junit.version>4.12</junit.version>
<lombok.version>1.16.6</lombok.version>
<objectify.version>5.1.9</objectify.version>
<stripe.version>1.38.0</stripe.version>

<appengine.version>1.9.32</appengine.version>
<gcloud.plugin.version>2.0.9.88.v20151125</gcloud.plugin.version>
<resources.plugin.version>2.7</resources.plugin.version>

(might have missed 1 or 2)


Solution

  • The fix was to change this dependency:

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
    </dependency>
    

    to this:

    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>${jersey.version}</version>
    </dependency>
    

    where ${jersey.version} is set to 2.5.1. No idea how this had been working so far...

    Realized this potential issue as I was reading Java RestFull WebService: JAX-RS implementation with Jersey 2.3.1 libraries and that is also when the comment by @peeskillet poppped up.