1

I have this error for maven-jetty-plugin. I think that this problem happens because of transit dependencies from plugin, which conflict with new libraries. This error appeared after I changed jersey1 to jersey2 and changed all dependencies from com.sun to org.glassfish for server client/core/rs-ws, etc.

[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2:run
 (default-cli) on project Plentify: Execution default-cli of goal org.eclipse.je
tty:jetty-maven-plugin:9.3.0.M2:run failed: An API incompatibility was encounter
ed while executing org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2:run: java.lang.
NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/stepan/.m2/repository/org/eclipse/jetty/jetty-m
aven-plugin/9.3.0.M2/jetty-maven-plugin-9.3.0.M2.jar
[ERROR] urls[1] = file:/C:/Users/stepan/.m2/repository/org/sonatype/sisu/sisu-in
ject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[2] = file:/C:/Users/stepan/.m2/repository/org/sonatype/sisu/sisu-gu
    ice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[3] = file:/C:/Users/stepan/.m2/repository/org/codehaus/plexus/plexu
s-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[4] = file:/C:/Users/stepan/.m2/repository/org/sonatype/aether/aethe
r-util/1.11/aether-util-1.11.jar
[ERROR] urls[5] = file:/C:/Users/stepan/.m2/repository/org/codehaus/plexus/plexu
s-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[6] = file:/C:/Users/stepan/.m2/repository/org/codehaus/plexus/plexu
s-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[7] = file:/C:/Users/stepan/.m2/repository/org/sonatype/plexus/plexu
s-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[8] = file:/C:/Users/stepan/.m2/repository/org/sonatype/plexus/plexu
s-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[9] = file:/C:/Users/stepan/.m2/repository/org/apache/maven/plugin-t
ools/maven-plugin-tools-api/3.1/maven-plugin-tools-api-3.1.jar
[ERROR] urls[10] = file:/C:/Users/stepan/.m2/repository/backport-util-concurrent
/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[11] = file:/C:/Users/stepan/.m2/repository/org/eclipse/jetty/jetty-
util/9.3.0.M2/jetty-util-9.3.0.M2.jar

And so on...

Can anyone answer how to avoid this kind of errors? Thanks.

UPDATE1: http://pastebin.com/ag2zdiSH link to full pom

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!-- JPA SQL Implementation -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.0-RC1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>commonj.sdo</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- JPA NoSQL Implementation -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.nosql</artifactId>
            <version>2.6.0</version>
        </dependency>
        <!-- Http Requests core -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4</version>
        </dependency>
        <!-- Common input output operations -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!-- Java Bean to JSON and vice versa implementation -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3</version>
            <type>jar</type>
        </dependency>
        <!-- mysql driver JDBC implementation -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.35</version>
        </dependency>
        <!-- mongo driver -->
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.0.0</version>
        </dependency>
        <!-- Logging -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>apache-log4j-extras</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- servlet container -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <!-- xml json web components -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>            
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.17</version>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.17</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>2.17</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.17</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <!-- Authorization -->
        <dependency>
            <groupId>org.apache.oltu.oauth2</groupId>
            <artifactId>org.apache.oltu.oauth2.authzserver</artifactId>
            <version>${oltu.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.oltu.oauth2</groupId>
            <artifactId>org.apache.oltu.oauth2.resourceserver</artifactId>
            <version>${oltu.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.oltu.oauth2</groupId>
            <artifactId>org.apache.oltu.oauth2.common</artifactId>
            <version>${oltu.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- Scheduler -->
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz-jobs</artifactId>
            <version>2.2.1</version>
        </dependency>
        <!-- Mail -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>

        <!-- Query -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-core</artifactId>
            <version>5.7.0</version>
        </dependency>
        <!-- Cache -->
        <dependency>
            <groupId>com.whalin</groupId>
            <artifactId>Memcached-Java-Client</artifactId>
            <version>3.0.2</version>
        </dependency>
    </dependencies>
Ivan Ivanov
  • 2,076
  • 16
  • 33

2 Answers2

1

Never mix com.sun.jersey (1.x) dependencies with org.glassfish.jersey (2.x) dependencies. They incompatible. The error you are seeing is the result of mixing these together.

All you really need to basic Jersey functionality is

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
    <version>2.17</version>
</dependency>

You can get rid of all the rest (of the Jersey dependencies) you have. For JSON (Jackson) support, use

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.17</version>
</dependency>

For Embedded Jetty (noticed your pom packaging is "jar") configuration, see this complete example. The JacksonFeature is to configure the Jackson support for JSON.

EDIT

After looking at your pom again. I don't see an Jetty dependencies, aside from the plugin. Maybe you're aren't trying to run an embedded instance. For web.xml configuration, you can use this as startup

<servlet>
    <servlet-name>jersey-serlvet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>
            you.can.list.a.comma.separated,
            list.of.packages.to.scan.for,
            resources.and.providers
        </param-value>
    </init-param>
    <!-- This doesn't really need to be included. 
         Just showing how to add manually. -->
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>
            org.glassfish.jersey.jackson.JacksonFeature
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

One thing that looks odd to me is that you have your packaging as jar. You sure it shouldn't be war (as it seems from your Jetty plugin configuration, you are running a webapp).

Community
  • 1
  • 1
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • Thanks. The very first problem was with com.sun.jersey json package. After I removed that code it started working. Then changed servlet com.sun.jersey.config.property.packages to jersey.config.server.provider.packages. Now I have two problems. 1) Server sometimes freezes on start. I need to open terminal window and click some keys, after that it starts working. 2) Interceptors still not found – Ivan Ivanov Jun 04 '15 at 11:09
0

I suggest you two approaches to fix the issue.

First of all I wouldn't use a milestone version of the plugin. I would probably go for a release version or at the very least a release candidate. You could try the 9.3.0.RC1 which is very recent.

If this doesn't solve your issue, you might want to try and update manually the dependency for javax.ws.rs-api in your POM. However I have the feeling you would then have troubles with jersey itself. Anyway, giving it a shot won't hurt. To figure out the correct version just use the dependency hierarchy on the POM before update.

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>XXX</version>
</dependency>
Marco Lenzo
  • 318
  • 2
  • 8