Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Jersey dependency to add to avoid NoClassDefFoundError for jersey.repackaged.com.google.common.collect.Maps

Tags:

java

jersey

I'm trying to run a a test that extends JerseyTest but when running it I'm getting a:

java.lang.NoClassDefFoundError: jersey/repackaged/com/google/common/collect/Maps

Any idea what dependency I'm missing? I've included the following jersey artifacts in my pom.xml and jersey.version is 2.5.1:

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>${jersey.version}</version>
    </dependency>

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

    <dependency>
        <groupId>com.sun.jersey.jersey-test-framework</groupId>
        <artifactId>jersey-test-framework-core</artifactId>
        <version>1.18</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.test-framework.providers</groupId>
        <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
        <version>2.6</version>
        <scope>test</scope>
    </dependency>
like image 385
Matt Avatar asked Feb 27 '14 13:02

Matt


1 Answers

You'll need:

<dependency>
  <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
  <artifactId>jersey-guava</artifactId>
  <version>2.6</version>
</dependency>

From http://blog.dejavu.sk/2014/02/21/jersey-2-6-has-been-released-new-and-noteworthy/

Jersey, from versions 2.6 for JAX-RS 2.0 and 1.18.1 for JAX-RS 1.1, no longer transitively brings Guava and ASM libraries to your application. This means that even when we still use them internally you can use different versions of these libraries. Classes from both of these libraries has been repackaged, jersey.repackaged.com.google.common and jersey.repackaged.objectweb.asm respectively, and shrinked to lower the footprint. ASM 5 is now part of jersey-server core module and for Guava we’ve created a separate bundle module jersey-guava as this dependency is widely used in multiple Jersey modules.

You're using the Jersey 2.6 jersey-test-framework-provider-grizzly2.

like image 130
Greg Kopff Avatar answered Sep 19 '22 04:09

Greg Kopff