Environment
Windows 7(64)
jdk1.7.0_51(64)
RESTEasy3.0.7
apache-tomcat-7.0.50
Project Name: hello
RESTEasyHelloWor
You could try to use http://localhost:8080/hello/RESTEasyHelloWorld/a. (Without the /rest).
If you want to use /rest, you can modify your RESTEasyHelloWorldService @Path to /rest/RESTEasyHelloWorld.
But based on the APIs versions you are using, you can do a much simpler job to get your restful service working.
I'm assuming you have resteasy-jaxrs lib on your classpath.
Since you are not using JBOSS or EAP, you also need to get resteasy-servlet-initializer. Documentation for using Servlet 3.0 Containers like TOMCAT here.
You will need to extend Application, creating for example a RESTEasyService:
@ApplicationPath("/rest")
public class RESTEasyService extends Application {
}
You don't need to provide any implementation for that class, since RESTEasy will scan for all providers and resources. Documentation for using Application class here.
Leave your RESTEasyHelloWorldService just like you said on your question:
@Path("/RESTEasyHelloWorld")
public class RESTEasyHelloWorldService {
@GET
@Path("/{param}")
@Produces(MediaType.TEXT_PLAIN)
public String getMsg(@PathParam("param") String name) {
String msg = "Rest say: good " + name;
return msg;
}
}
Now your web.xml doesn't need anything. Java WS-RS and RESTEasy are already doing everything.
Your web.xml can be like this:
hello
RESTEasy official documentation is a little confusing at start, but once you understand that the implementation is the same for JBOSS and NON-JBOSS apps (just the use of libs that change), you get things going easier.