Help with "java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map"

10,953 views
Skip to first unread message

Rohit Jamuar

unread,
Dec 1, 2014, 7:26:45 PM12/1/14
to dropwiz...@googlegroups.com
Hi,

I have been trying to write an integration test (using DropwizardAppRule ) for my DW application. After successfully loading configurations and starting the application, I keep running into "java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map" exception. I tried googling for a solution; from the entries in StackOverflow, it seems that such an exception arises when there is some conflict between a newer version of Jersey with a prior version. Going through the dependency hierarchy in my pom.xml, I cannot locate a conflict which could trigger this exception. I'm not sure what's the root cause for this : this is seen in the logs org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED
 with -
org.eclipse.jetty.server.Server
org.eclipse.jetty.server.handler.StatisticsHandler
org.eclipse.jetty.server.handler.RequestLogHandler
io.dropwizard.jetty.RoutingHandler
com.codahale.metrics.jetty9.InstrumentedHandler
i.d.j.MutableServletContextHandler

Help would be much appreciated!

Thanks,
Rohit



Jonathan Grimm

unread,
Dec 2, 2014, 10:34:17 AM12/2/14
to dropwiz...@googlegroups.com
We're seeing this when using the current 0.8 snapshot.

Michael Hixson

unread,
Dec 4, 2014, 3:58:48 AM12/4/14
to dropwiz...@googlegroups.com
For me, this error came from me importing both Jersey 1 and 2 in my pom.xml.  The Jersey 2 dependency was implied through Dropwizard 0.8, and the Jersey 1 dependency was explicit because I was depending on this:  http://search.maven.org/#artifactdetails%7Ccom.sun.jersey%7Cjersey-client%7C1.18.3%7Cjar

If you do "mvn dependency:tree" from the command line, do you see any references to the com.sun.jersey jersey-client?

-Michael

Rohit Jamuar

unread,
Dec 4, 2014, 10:52:14 AM12/4/14
to dropwiz...@googlegroups.com
Hi Michael,

After running "mvn dependency:tree", I see "org.glassfish.jersey.core:jersey-client:jar:2.13:compile" on STDOUT. Do you know how to troubleshoot this?

Thanks,
Rohit

Michael Hixson

unread,
Dec 4, 2014, 6:55:32 PM12/4/14
to dropwiz...@googlegroups.com
Hi Rohit,

That is the correct version of the client, so it doesn't look like that's the problem.

In the dependency tree, do you see any references to "com.sun.jersey:jersey-core:jar:1.18.3" (or any 1.* version)?

The issue is that you have multiple versions of the class "javax.ws.rs.core.Application" on your classpath.  The Application from old versions of Jersey didn't have that "public Map<String, Object> getProperties()" method, and that old Application is getting loaded instead of the new one and causing your error.

If you figure out which of your dependencies is causing com.sun.jersey:jersey-core to be included, you have a couple of options for trying to fix it:

1) See if there is an updated version for that library on Maven central which is compatible with Jersey 2.

2) Exclude the jersey-core dependency manually and hope the library still works.  For example, if you're depending on a "foo.bar:baz-library" in your pom.xml, and that's what is depending on the old Jersey version, you could add an <exclusions> section in the <dependency> tag for foo.bar:

   <dependency>
    <groupId>foo.bar</groupId>
    <artifactId>baz-library</artifactId>
    <version>1.0</version>
      <exclusions>
        <exclusion>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-core</artifactId>
        </exclusion>
      </exclusions>
  </dependency>

(I could be wrong about all of this, but I'm pretty sure this is the basic problem here)

-Michael

Rohit Jamuar

unread,
Dec 5, 2014, 2:16:04 PM12/5/14
to dropwiz...@googlegroups.com
Hi Michael,

Thanks for the input! There was a rogue jersey jar (v1.9) dangling in one of the poms; removing that fixed the issue.

Thanks,
Rohit

Thanks,
Rohit
Reply all
Reply to author
Forward
0 new messages