0

当我尝试在本地主机上使用 JAXRS 访问 Restful Web 服务时,我收到下面提到的错误。我确实检查了重复的 jar 文件,甚至我的 web.xml 似乎都是正确的。知道我哪里出错了吗?

错误(i):[尝试访问本地主机时]

在此处输入图像描述

错误(ii):[在 Eclipse 控制台中]

INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
May 10, 2012 2:08:19 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /validatorService threw load() exception
javax.servlet.ServletException: Resource configuration class, validatorService.ValidatorServiceConfig, is not a super class of class javax.ws.rs.core.Application
    at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:741)
    at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

May 10, 2012 2:08:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files (x86)\apache-tomcat-7.0.27\webapps\docs
May 10, 2012 2:08:19 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files (x86)\apache-tomcat-7.0.27\webapps\examples
May 10, 2012 2:08:20 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 10, 2012 2:08:20 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
May 10, 2012 2:08:20 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@79e582c1')
May 10, 2012 2:08:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files (x86)\apache-tomcat-7.0.27\webapps\host-manager
May 10, 2012 2:08:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files (x86)\apache-tomcat-7.0.27\webapps\manager
May 10, 2012 2:08:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files (x86)\apache-tomcat-7.0.27\webapps\ROOT
May 10, 2012 2:08:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 10, 2012 2:08:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 10, 2012 2:08:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 675 ms

错误 (iii) Apache / 日志

127.0.0.1 - - [10/May/2012:14:28:18 -0500] "GET / HTTP/1.1" 200 11444
0:0:0:0:0:0:0:1 - - [10/May/2012:14:28:18 -0500] "GET /validatorService/WEB-INF/classes/validatorService/ValidatorService.java HTTP/1.1" 404 952
0:0:0:0:0:0:0:1 - - [10/May/2012:14:28:34 -0500] "GET /validatorService/rest/ HTTP/1.1" 500 2604
0:0:0:0:0:0:0:1 - - [10/May/2012:14:28:39 -0500] "GET /validatorService/rest/valid HTTP/1.1" 500 2604
0:0:0:0:0:0:0:1 - - [10/May/2012:14:28:52 -0500] "GET /validatorService/rest/valid HTTP/1.1" 500 2604
4

1 回答 1

2

应该想通了,我一看到这个就知道了。无论如何,这就是我的错误

错误:

javax.servlet.ServletException: Resource configuration class, validatorService.ValidatorServiceConfig, is not a super class of class javax.ws.rs.core.Application

使固定:

public class ValidatorServiceConfig extends Application

前:

public class ValidatorServiceConfig
于 2012-05-14T14:59:28.573 回答