I am trying to make a simple resteasy based API using JAVA 8 (v45) and tomcat 8(v23), however I don't see my calls resulting in any traffic or log activity.
My web.xml looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd"
version="3.0">
<display-name>Test</display-name>
<description>Test</description>
<servlet>
<servlet-name>resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy</servlet-name>
<url-pattern>/restfulservices/*</url-pattern>
</servlet-mapping>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this should be the same URL pattern as the servlet-mapping property -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/restfulservices</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/cboxDs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- Environment entry examples -->
<env-entry>
<env-entry-name>test</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>dev</env-entry-value>
</env-entry>
</web-app>
and my service class looks like this:
package test.request.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.apache.log4j.Logger;
@Path("/dihService")
public class testService {
private static final Logger LOGGER = Logger.getLogger(testService.class);
@GET
@Path("/hello")
public Response getResponseMessage() {
LOGGER.info(" Entered and param is :");
return Response.status(200).entity(" Entered. Hello world").build();
}
}
After I deploy, when i hit the following URL : http://localhost:10120/resteasy/restfulservices/dihService/hello
I expect some activity in the logs, however I am not seeing anything. I have already verified that my server is running on port 10120 and that my logs are otherwise flowing normally. Any ideas??
Your servlet config is mapped to URL that starts with /restfulservices as mentioned here:
but your actual web service class does not use that URL part
so it will not be found. You need add
restfulservices
to your class mapping path as mentioned here: