I create a simple web service using Eclipse WTP. Tomcat version is 8.5 and Java is 1.8.
I downloaded Jersey 2.27. When starting the Server from Eclipse, I receive the following error:
java.lang.RuntimeException: A class file of the class name, my.simple.webservice.SimpleWebService is identified but the class could not be found.
Any helps to resolve this is very much appreciated.
Searching on StackOverflow and other site did not return any useful information.
My web service looks like this:
package my.simple.webservice;
...imports ...
@Path("/")
public class SimpleWebService {
@POST
@Path("/service")
@Consumes(MediaType.APPLICATION_JSON)
public Response consumeService(InputStream incomingData) {
/*
*do stuff here with the JSON
*/
// return HTTP response 200 in case of success
return Response.status(200).entity(myStringBuilder.toString()).build();
}
@GET
@Path("/verify")
@Produces(MediaType.TEXT_PLAIN)
public Response verifyRESTService(InputStream incomingData) {
String result = "My Simple web service Successfully started..";
// return HTTP response 200 in case of success
return Response.status(200).entity(result).build();
}
}
My web.xml looks like this:
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>my.simple.webservice</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
clean
install
by maven buildIf it still does not work let me know, i will replicate the problem on my system.