Jersey - Eclipse - Tomcat - 404

MoBau

I know, this question has been discussed a lot of times. However, I cannot resolve the problem... I'm trying to set up a new JAX-RS web service, accessing a static index.html file works fine, however, as soon as I try to request the service I get a 404 error.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>ticketing</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>ticketing</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>jersey.config.server.provider.packages</param-name>
      <param-value>com.baumotte.ticketing.endpoints</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>ticketing</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
</web-app>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.baumotte</groupId>
  <artifactId>Ticketing</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <release>10</release>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.glassfish.jersey.containers</groupId>
      <artifactId>jersey-container-servlet</artifactId>
      <version>2.27</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.core</groupId>
      <artifactId>jersey-server</artifactId>
      <version>2.27</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.core</groupId>
      <artifactId>jersey-client</artifactId>
      <version>2.27</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.inject</groupId>
      <artifactId>jersey-hk2</artifactId>
      <version>2.27</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>
  </dependencies>
</project>

Service Class:

package com.baumotte.ticketing.endpoints;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@ApplicationPath("/tickets")
public class TicketEP {

    @GET
    //@Produces(MediaType.TEXT_PLAIN)
    public String getTickets() {
        return "hello world";
    }

}

I'm trying to access the web service on localhost:8080/ticketing/rest/tickets/. Accessing index.html on localhost:8080/ticketing/ works fine as per the welcome-file-list attribute. Do you have an idea of what I'm missing there? (btw. I'm using Eclipse Photon release with Tomcat 9.0)

MoBau

Solution: ApplicationPath must be Path in class TicketEP:8

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Jersey tomcat and eclipse: error 404

Error 404 Jersey Tomcat Eclipse Web service

404 Error for a Jersey Tomcat web server created in eclipse with java

Tomcat Jersey throws 404

Jersey Services with Tomcat and Eclipse

Getting 404 when running jersey-quickstart-webapp on tomcat 9 in eclipse

Eclipse, tomcat, 404 error

Eclipse Tomcat Error 404

Restful webservices with jersey and tomcat error: 404

404 error with Jersey REST Service on Tomcat

Jersey + Jetty + Gradle 404 Error - but works in Tomcat

Getting 404 error with TOMCAT-Jersey Rest

How to deploy a REST (Jersey) serivce on Tomcat in Eclipse

404 error with Rest Service - Jersey/tomcat8

Server always returns 404 Error with Jersey 2 + Tomcat 6

Jersey 2.25 and Tomcat 9.0.33 always responding 404 Not found

Java - Accessing Tomcat/Jersey url gives 404 Not Found

Eclipse & Tomcat Error: HTTP Status 404 – Not Found:

404 error when running tomcat on eclipse

HTTP Status 404 Not Found For Jersey REST application with Eclipse and Payara server

Tomcat running from command prompt but shows 404 Error in eclipse

Perfectly Fine Working Eclipse Project throws 404 on Tomcat

HTTP Status 404 - on Eclipse with Tomcat (with no generated web.xml)

Jersey servlet exception tomcat jersey

How I return HTTP 404 JSON/XML response in JAX-RS (Jersey) on Tomcat?

Jersey JAX-RS REST 404 in Openshift, working well in local Tomcat

Getting 404 while trying to access endpoints using Jersey 3 and Tomcat 10

jersey webservices 404 error

Rest app (Jersey/JAX-RS) runs in glassfish through eclipse but not when deployed in tomcat

TOP Ranking

HotTag

Archive