0

I've been struggling with deploying JAX-WS RESTful services to Tomcat 8 from Netbeans. My dev env is as follows: - Windows 8.1 - Netbeans 8.0.2 - Tomcat 8.0.9.0 (bundled with Netbeans along with GlassFish 4.1) - jdk1.7.0_51 - javaee-web-api-7.0.jar which has JAX-WS as part of it

My web app is a Maven project. Neatbeans deploys it to GlassFish 4.1 and runs just fine, with all REStful services working as expected. When I deploy to Tomcat, the WAR deploys and the web app seems to initialize, with the following lines present in the Tomcat startup log, which seem ok: 30-Aug-2015 17:43:04.318 INFO [localhost-startStop-1] org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.addServletWithApplication Registering the Jersey servlet application, named com.uristic.webrest.ApplicationConfig, at the servlet mapping /webresources/*, with the Application class of the same name. 30-Aug-2015 17:43:05.028 INFO [localhost-startStop-1] org.glassfish.jersey.server.ApplicationHandler.initialize Initiating Jersey application, version Jersey: 2.5.1 2014-01-02 13:43:00...

However, the WS URLs return 404.

The POM file looks like this:

<modelVersion>4.0.0</modelVersion>

<groupId>org.mygroup</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>myproject</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

I researched this site as well as other Web resources, then tried quite a few recommended things, including adding the cargo plugin to the POM, still to no avail. I'm probably missing something important about Tomcat (which i'm new to) and need an expert help, please.

Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66
  • Seems to be a duplicate of [this](http://stackoverflow.com/q/29732625/2587435) – Paul Samsotha Aug 31 '15 at 04:54
  • Thanks peeskillet, I tried to add the dependency recommended in that post which you pointed to, and it didn't work for me. When I added the dependency upon the jersey-container-servlet, it added a bunch of Jersey jars as dependencies in Netbeans and stopped working for me even in ClassFish, not to mention Tomcat. Looks like the javaee-web-api dependency in my original pom is all what is needed for GlassFish to run my project fine. The corresponding javaee-web-api-7.0.jar includes the required ws.rs api and all. However, it does not work in Tomcaut 8. How do I make my project work in Tomcat? – JackReacher Aug 31 '15 at 22:01
  • Update: the pom dependency pointed out by peeskillet in fact works! The problem was that REST web services which I was testing used the @RequestScoped annotation (I started with a sample REST service code from somewhere) hence introducing a dependency upon something like javax.enterprise.context.RequestScoped. Once that dependency was removed, and that one form the post mentioned by peeskilled added, my project was up and running in Tomcat 8 just fine. – JackReacher Aug 31 '15 at 23:14
  • Thanks a lot, peeskillet!! – JackReacher Aug 31 '15 at 23:15
  • Another thing, if you are going to deploy to tomcat, you should get rid of the javaee-api jar so you don't mistakenly try and use some EE feature that tomcat does not have the implementation for. Remember, tomcat is not an EE server. If you want to be able to use classes like `HttpServletRequest`, then you just need to add the [javax.servlet-api](http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/3.1.0) – Paul Samsotha Sep 01 '15 at 00:56

0 Answers0