web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
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">
<servlet>
<display-name>JAX_RS_Servlet</display-name>
<servlet-name>JAX_RS_Servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX_RS_Servlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
代码如下:
错误提示: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)