0

Configuration and idea: I have maven 3.3, eclipse mars, tomcat v8, and want to deploy first a simple helloworld servlet and then my own code to test it.

I've been trying for some days to do this, I couldn't even get into apache main page, and just now got it configured right so I see my web service in the manager webapp. However, it's giving me 404 status for a helloworld, which is not something I expected.

So I wanted to know what should I try next. I have the code, I see it deployed in tomcat, tomcat is working, but nothing rest/servlet related works, it's just 404 status.

I'm trying to access mainly through this two combinations of paths:

http://localhost:8080/connectedCar/

http://localhost:8080/connectedCar/rest/helloworld

pom:

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.9</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
            <version>1.17.1</version>
        </dependency>

    </dependencies>

web.xml:

<servlet>
    <servlet-name>connectedCar</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>jersey.config.server.provider.packages</param-name>
      <param-value>pruebaCC.connectedCar</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>connectedCar</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

tomcat users:

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
-->

    <role rolename="manager-gui"/>
    <user username="admin" password="admin" roles="manager-gui"/>

</tomcat-users>

setting.xml:

<server>
    <id>tomcatserver</id>
    <username>admin</username>
    <password>admin</password>
</server>
monkey intern
  • 705
  • 3
  • 14
  • 34

2 Answers2

1

Please change the init param to com.sun.jersey.config.property.packages for Jersey 1. The one you're using is applicable to Jersey 2.

Also, look at this answer for minimal Jersey 1 set up ServletContainer class not found Exception

Community
  • 1
  • 1
s7vr
  • 73,656
  • 11
  • 106
  • 127
  • I will, thank you very much. I only even have jersey because something else was failing hard, so after a lot of searching I saw what I have posted as a solution. I'll try and change it, thanks. – monkey intern Jun 08 '16 at 12:03
1

The actual URL format to access a web resource is

http://<host>:<port>/<web_context_path>/<url_pattern>/<web_services_path>
sitakant
  • 1,766
  • 2
  • 18
  • 38