1
votes

I have a Java EE app that uses EJB 3, JPA, JAX-RS and CDI. I included jetty maven plugin and want to specify dependencies that implement the APIs that are missing in jetty. I used the following dependency list and jetty configuration.

<plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.3.3.v20150827</version>
            <configuration>
                <jettyXml>src/test/resources/jetty.xml</jettyXml>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <version>1.4.192</version>
                </dependency>
                <dependency>
                    <groupId>com.mchange</groupId>
                    <artifactId>c3p0</artifactId>
                    <version>0.9.5.2</version>
                </dependency>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-entitymanager</artifactId>
                    <version>5.2.2.Final</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.openwebbeans</groupId>
                    <artifactId>openwebbeans-impl</artifactId>
                    <version>1.6.3</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.openejb</groupId>
                    <artifactId>openejb-core</artifactId>
                    <version>4.7.4</version>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.containers</groupId>
                    <artifactId>jersey-container-servlet</artifactId>
                    <version>2.23.2</version>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.media</groupId>
                    <artifactId>jersey-media-json-jackson</artifactId>
                    <version>2.23.2</version>
                </dependency>
            </dependencies>
        </plugin>

Then my jetty.xml config is this

<Configure id ="h2" class="org.eclipse.jetty.webapp.WebAppContext">
  <New id="h2Datasource" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg>jdbc/h2</Arg>
      <Arg>
        <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
          <Set name="driverClass">org.h2.Driver</Set>
          <Set name="jdbcUrl">jdbc:h2:./target/db/testdb</Set>
          <Set name="user">sa</Set>
          <Set name="password"></Set>
        </New>
      </Arg>
   </New>
 </Configure>

But then when I do mvn clean package jetty:run I get this exception:

[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.3.v20150827:run (default-cli) on project dip-cv-web: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.3.3.v20150827:run failed: An API incompatibility was encountered while executing org.eclipse.jetty:jetty-maven-plugin:9.3.3.v20150827:run: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

I can provide more details if needed. Not sure what else you might find helpful to help me debug this issue.

Thanks!

1
I could found out that when I comment out the openejb dependency it's not causing that issues above, but this is not helping me as I need ejb support. Might be that jax-rs implementation conflicts with the openejb in some way?stefo0O0o

1 Answers

0
votes

You usually get "NoSuchMethodError" when you are having two different versions of the class on your class path. As the javax.ws.rs.core.Application class does have the getProperties() method in its JAX-RS 2 version, but not in JAX-RS 1.x.

You can get the dependency tree using following maven command

mvn dependency:tree -Dverbose -Dincludes=javax.ws.rs

 --- maven-dependency-plugin:2.8:tree (default-cli) @ language-processing ---
- +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.23.2:compile
- |  +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.23.2:com
- |  |  \- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)
- |  +- org.glassfish.jersey.core:jersey-common:jar:2.23.2:compile
- |  |  \- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)
- |  +- org.glassfish.jersey.core:jersey-server:jar:2.23.2:compile
- |  |  +- org.glassfish.jersey.core:jersey-client:jar:2.23.2:compile
- |  |  |  \- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate
- |  |  \- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)
- |  \- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
- \- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.23.2:compile
-    \- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.23.2:compile
-       \- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)

your jersey-container-servlet dependency brings javax.ws.rs-api-2.0.1.jar