Here is my url; http://localhost:2222/test1/test1/home/hello
This url causes the error below. HTTP ERROR 404 Problem accessing /test1/test1/home/hello. Reason: Not Found
And main servlet starter and resource class below
ResourceConfig config = new ResourceConfig();
config.packages("java"); // this is where my main class and resource resides
ServletHolder servlet = new ServletHolder(new ServletContainer(config));
Server server = new Server(2222);
ServletContextHandler context = new ServletContextHandler(server, "/test1",ServletContextHandler.NO_SESSIONS);
context.addServlet(servlet,"/test1");
try
{
server.start();
server.join();
}
catch(Exception ex){
ex.printStackTrace();
server.destroy();
}
My Resource
@Path("/home")
public class Resources {
@GET
@Path("/hello")
@Produces(MediaType.TEXT_PLAIN)
public String helloWorld() {
return "Hello, world!";
}
}
What am i doing wrong?
Edit:I think problem is in "packages" part but i dont know how to configure it. Thanks