I have a problem trying to use Jersey on my Tomcat server. When I run my server and then try to go on the url "http://localhost:8080/RssApp/rest/test" I have the following error (RssApp is the name of my project):
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
Here is my web.xml file:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>CreateAccount</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.team.RssServlet.CreateAccount</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CreateAccount</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
and here my servlet:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("test")
public class CreateAccount{
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return "Got it!";
}
}
I read on internet that it could come from
com.sun.jersey.config.property.packages
like a wrong name or something, so just to see what type of error I would have I deleted "es" at the end to have just:
com.sun.jersey.config.property.packag
I was expecting an error but I didnt had one, and then when I try with the url "http://localhost:8080/RssApp/rest/test" my browser displayed me "Got it!" lol.
I'm kind of lost, and I'm new to the JEE and web in general.
Thanks for your help.