REST API runs on devserver, but is missing constructor on AppEngine

21 views
Skip to first unread message

Robert Lill via StackOverflow

unread,
Oct 11, 2016, 6:15:06 AM10/11/16
to google-appengin...@googlegroups.com

I have created a REST interface on AppEngine using Jersey 2.23.2

Running the local devserver works fine, but if I deploy it to AppEngine, API-calls cause a 500 error and the log contains this exception:

Uncaught exception from servlet
java.lang.NoSuchMethodError: org.glassfish.jersey.server.ApplicationHandler.<init>
  (Ljavax/ws/rs/core/Application;Lorg/glassfish/hk2/utilities/Binder;)V
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:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
...

(Full stack at http://pastebin.com/R1j7CzxK)

I spent quite some effort eliminating any jar conflicts as suggested here, so finally my pom looks like http://pastebin.com/m6UEB3E4.

This is the relevant section of my web.xml:

<servlet>
    <servlet-name>MyManager</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>my.package.controller.ApiController</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>my.package.controller</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>MyManager</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

What could be causing this error and how can I fix it? Any experiences?



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39974971/rest-api-runs-on-devserver-but-is-missing-constructor-on-appengine

Robert Lill via StackOverflow

unread,
Oct 11, 2016, 11:40:14 AM10/11/16
to google-appengin...@googlegroups.com

Found the solution: when calling

mvn appengine:update

without clean, maven doesn't remove previous versions of JARs from WEB_INF/libs, which in my case led to a whole mess of conflicting JARs on AppEngine.

mvn clean appengine:update

did the trick. For those struggeling with similar errors, here is my final POM: http://pastebin.com/XeFtw77d



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39974971/rest-api-runs-on-devserver-but-is-missing-constructor-on-appengine/39981203#39981203
Reply all
Reply to author
Forward
0 new messages