I have created a web app Maven project that is using RestEasy as a RESTful application framework.
My web.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>me.randytan.inconium</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/v1/api</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/v1/api/*</url-pattern>
</servlet-mapping>
</web-app>
I have set the automatic scan to true and created a few classes that cater for my endpoint access.
But the problem is, my browser throws "404 not found", even though I have already specified the endpoint params as written in my classes.
Sample endpoint URL: http://localhost:8080/me.randytan.inconium/v1/api/app/test
This is my sample class i made:
package me.randytan.inconium.controller;
import java.sql.Connection;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
@Path("app")
public class AppTransaction {
public AppTransaction(){ //do something
}
@GET
@Path("/test")
public String test(){
return "Hello World";
}
...
I have tried to change the @Path in the class to be:
@Path("/app")@Path("app")
and the path inside the function test() to be:
@Path("/test")@Path("test")
But neither works.
The specification for my project:
- Java 1.7
- Tomcat 7.0
- RestEasy 3.0.14
me.randytan.inconiumin it? - Darshan Lilame.randytan.inconium- randytan