Question

My webapp includes REST web services and is running on GlassFish 3.1.2.

I would like to run this app on Tomcat 7 instead of GlassFish. What dependencies should I add and remove to enable REST services on Tomcat?

(At the moment I just changed "GlassFish" to "Tomcat" in the "Run" menu of Netbeans, but my http requests give a 404.)

Note: this is a Maven project on Netbeans.

Was it helpful?

Solution

Ok here is the list of dependencies you may need. Please note I just put latest version but you may want to use a different version. Please also check for compatibility of these versions with each other.

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

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
</dependency>

Needed if you are using jackson to parse json

<dependency>
    <groupId>com.fasterxml.jackson.jaxrs</groupId>
    <artifactId>jackson-jaxrs-json-provider</artifactId>
    <version>2.3.3</version>
</dependency>

This is what I am using on my tomcat but little bit older versions

Now about your 404
First check if the dependencies fix your problem. 404 may be an issue from some thing not configured right in your web.xml as well.

I hope it helps you solve your problem :)

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