I have been searching for so many days and I can't find any solution or where is the problem so please don't mark the question as repeated because it's really not. I read all the questions and the answers, I tried all the solutions and still not working.
I am using Intellij, Jersey 2.25 and Tomcat 9.0.33. I am not allowed to use maven so I download all the jar dependencies manually and then reference them from the project structure window by adding them to the libraries and artifacts. The server is deployed successfully and when I open http://localhost:8080/ofar_war_exploded/ it shows the content of the index.jsp file. However, when I try to access a resource for example a simple method that returns a string in my OptimizerResource class I get the following response
HTTP Status 404 – Not Found Type Status Report Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. Apache Tomcat/9.0.33
The lib folder contains all the dependencies needed. I tried to add also the lib folder inside WEB-INF I got the same behavior. This is the list of all the jars I am using
This is the content of the web.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>Optimizer Service</display-name>
<servlet>
<servlet-name>optimizer</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>rest.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>optimizer</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Just for a testing wise I added only one get method in the OptimizerResource class that returns hello. When I try to request this url http://localhost:8080/ofar_war_exploded/rest/optimizer/hello I receive 404 not found.
@Path("optimizer")
public class OptimizerResource {
@GET
@Path("hello")
@Produces("text/plain")
public String getHello() {
return "Hello";
}
}
There were a mistake in the dependencies, they were incorrect. The working set of dependencies are as follow: List of Dependencies
The List of all jersey bundles with complete dependencies Link
Or you can download jersey download the full dependencies bundle from this Link