I am trying to deploy a simple application that displays the status of a restful service using jersey and glassfish 4. I am getting the following exception:
org.glassfish.jersey.internal.ServiceConfigurationError:
org.glassfish.jersey.internal.spi.AutoDiscoverable: The class
org.glassfish.jersey.server.internal.monitoring.MonitoringAutodiscoverable implementing
provider interface org.glassfish.jersey.internal.spi.AutoDiscoverable could not be
instantiated: Cannot cast
org.glassfish.jersey.server.internal.monitoring.MonitoringAutodiscoverable to
org.glassfish.jersey.internal.spi.AutoDiscoverable
My web.xml looks like this
<web-app>
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
My service looks like this:
@Path(MyServices.SERVICE_URL)
public class MyServices
{
@GET
@Produces("text/html")
public String getStatus()
{
return "My service is running.";
}
}
Does anyone knows what I am doing wrong here?
Edit I added this class to my war project:
@ApplicationPath("/*")
public class MyApplication extends ResourceConfig
{
public MyApplication()
{
packages("com.java.services");
}
}
and I am still getting the same exception:
javax.servlet.ServletException: Servlet.init() for servlet com.java.services.MyApplication threw exception