com.sun.jersey.api.container.ContainerException

xiaoxiao2021-02-28  20

写代码时出现了这样的报错信息

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:103) at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1182) at com.sun.jersey.server.impl.application.WebApplicationImpl.access$600(WebApplicationImpl.java:161) at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:698) at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:695) at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:197) at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:695) at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:690) at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:438) at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:287) at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:587) at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:213) at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:342) at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:516) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

这是因为 使用向导创建web工程时 自动在 web.xml文件内生成了一个Servlet的

<servlet> <description>JAX-RS Tools Generated - Do not modify</description> <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>/jaxrs/*</url-pattern> </servlet-mapping>

启动服务器加载项目,就会去xml中加载这个servlet而实际上我们并没有创建这个 JAX-RS Servlet 所以将对应的servlet 和servlet-mapping 标签注掉或者删掉就可以了

<!-- <servlet> <description>JAX-RS Tools Generated - Do not modify</description> <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>/jaxrs/*</url-pattern> </servlet-mapping> -->

然后,重新启动服务器,就不会再报错

三月 10, 2018 4:54:05 下午 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8. 三月 10, 2018 4:54:05 下午 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 三月 10, 2018 4:54:06 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized (OpenSSL 1.0.1e 11 Feb 2013) 三月 10, 2018 4:54:07 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-apr-8080"] 三月 10, 2018 4:54:07 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["ajp-apr-8009"] 三月 10, 2018 4:54:07 下午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 2989 ms 三月 10, 2018 4:54:07 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 三月 10, 2018 4:54:07 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.53 三月 10, 2018 4:54:07 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory E:\software\tomcat7\apache-tomcat-7.0.53\webapps\docs 三月 10, 2018 4:54:08 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory E:\software\tomcat7\apache-tomcat-7.0.53\webapps\examples 三月 10, 2018 4:54:09 下午 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextInitialized() 三月 10, 2018 4:54:09 下午 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextInitialized() 三月 10, 2018 4:54:09 下午 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@473bb93a') 三月 10, 2018 4:54:09 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory E:\software\tomcat7\apache-tomcat-7.0.53\webapps\host-manager 三月 10, 2018 4:54:09 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory E:\software\tomcat7\apache-tomcat-7.0.53\webapps\lst 三月 10, 2018 4:54:13 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory E:\software\tomcat7\apache-tomcat-7.0.53\webapps\manager 三月 10, 2018 4:54:13 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory E:\software\tomcat7\apache-tomcat-7.0.53\webapps\ROOT 三月 10, 2018 4:54:13 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-apr-8080"] 三月 10, 2018 4:54:13 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-apr-8009"] 三月 10, 2018 4:54:13 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 6809 ms
转载请注明原文地址: https://www.6miu.com/read-2150117.html

最新回复(0)