I am trying to make a web service with Tomcat and Eclipse using the jersey library. This is my class of service:
package com.gontuseries.university; import javax.ws.rs.core.MediaType; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/university") public class UniversityRestWs { @GET @Produces(MediaType.TEXT_HTML) public String getHtmlUniversityInfo(){ return "<html><body>test</body></html>"; } @GET @Produces(MediaType.TEXT_PLAIN) public String getTextUniversityInfo(){ return "test"; } }
And this is the web.xml file
<servlet> <servlet-name>Jersey REST Service</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.gontuseries.university</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Jersey REST Service</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping>
When I test my service, I get java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer I loaded the jersey from https://jersey.java.net/download.html
Can someone help me? Thanks
java eclipse tomcat jersey
user2607498
source share