当我尝试在localhost上使用JAXRS访问Restful Web服务时,我收到下面提到的错误。我确实检查了重复的jar文件,甚至我的web.xml似乎都是正确的。知道我哪里错了吗?
错误(i):[尝试访问localhost时]
错误(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 / log
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
答案 0 :(得分:2)
一见到这一点,应该已经弄清楚了。无论如何,这就是我的错误
ERROR:
javax.servlet.ServletException: Resource configuration class, validatorService.ValidatorServiceConfig, is not a super class of class javax.ws.rs.core.Application
FIX:
public class ValidatorServiceConfig extends Application
在:
public class ValidatorServiceConfig