Question

I attempt to deploy a very simple RESTful Web Service using Jersey 1.18 within Tomee 1.5.2 WebProfile. My project is fully inspired from the tomee-jersey-eclipselink

example that I further simplified by removing the persistence part: the Web Service simply retuns "Hello, World!"

@Path("/hello")
@RequestScoped
public class HelloService {

    public HelloService() {
    }

    @GET
    public String test() {
        return "Hello, World!";
    }
}

My dependencies in my POM:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.18</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.18</version>
    </dependency>
</dependencies>

I deploy my Web Service with the agnostic Application model:

import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

public class JerseyApplication extends Application {

    @Override
    public Set<Class<?>> getClasses() {
        final Set<Class<?>> classes = new HashSet<Class<?>>();
        classes.add(HelloService.class);
        return classes;
    }
}

And here is my web.xml:

<web-app>
  <servlet>
    <servlet-name>Jersey Web Application</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>org.superbiz.service.JerseyApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey Web Application</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

I also added the following property in $TOMEE/conf/system.properties:

com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true

Everything works fine with Tomcat 7 (In this case, I replace the javax:javaee-api dependency by javax.enterprise:cdi-api:1.1 in the POM), but when I try with Tomee, I just get a 404 HTTP status, with no exception and no additional logging message.

The result is the same whenever I deploy the application from my Eclipse IDE or with Maven in command line.

Note:

  • I do not want to use Tomee JAX-RS with Apache CXF, and I cannot upgrade to Tomee 1.6.
  • I already tried all possible ways from this post, that did not help.

Any idea ?

Was it helpful?

Solution

There was an issue resolved in TomEE 1.7.0 that fixed this problem. As the issue notes, you also need to add the following line to your catalina.properties:

openejb.classloader.forced-load=javax.ws.rs

This worked for me with Jersey 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top