om.sun.jersey.api.container.ContainerException: The ResourceJersey 发布WebService

web.xml


    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 
      JAX_RS_Servlet
      JAX_RS_Servlet
     
          com.sun.jersey.spi.container.servlet.ServletContainer
     

      1
 

 
      JAX_RS_Servlet
      /services/*
 

 
    index.jsp
 

代码如下:

错误提示:The ResourceConfig instance does not contain any root resource classes.

翻译后:资源配置实例未包含任何根资源类

 

解决方法:在代码类上添加 resource 注解

@Path("/hello")
public class HelloWorld {
    @GET
    @Produces("text/plain")
    public String sayHello(){
        return "Hello World";
    }
}


二月 12, 2015 5:19:53 下午 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /webserviceApp threw load() exception
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
    at com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:753)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:625)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:414)
    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:377)
    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:242)
    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:449)

你可能感兴趣的:(WebService,The,ResourceConfig,instance,does,not,contain,any,root,resource,classe)