Tomcat服务器因未知原因而遇到404

时间:2017-05-26 15:18:59

标签: spring maven spring-mvc tomcat

我试图使用Maven在Tomcat 8上作为服务器运行。我是这两个人的新手,所以我有一个我尚未制作的示例文件,应该打印“欢迎”#。 但是,我收到此错误

  

请求的资源不可用。

我检查了TomCat登录我的IDE(Netbeans),我发现它出现了这个错误:

  

org.apache.catalina.core.ApplicationContext.log初始化Spring root WebApplicationContext   2017年5月26日19:22:50.151 INFO [http-nio-8080-exec-76] org.apache.catalina.core.ApplicationContext.log将servlet court标记为不可用   2017年5月26日19:22:50.151严重[http-nio-8080-exec-76] org.apache.catalina.core.StandardContext.loadOnStartup Web应用程序[/ ronak]中的Servlet [court]抛出load()异常     java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet       在org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)       在org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)       at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:509)       在org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:490)       在org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)       在org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)       在org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1027)       在org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5038)       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5348)       在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)       在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)       在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)       在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)       在org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)       在org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:461)       在org.apache.catalina.startup.HostConfig.check(HostConfig.java:1612)       at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       在java.lang.reflect.Method.invoke(Method.java:497)       at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)       at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)       at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)       在org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1451)       在org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:897)       在org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:335)       在javax.servlet.http.HttpServlet.service(HttpServlet.java:622)       在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)       在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)       在org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)       在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:616)       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)       at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:684)       在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1533)       在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1489)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)       在java.lang.Thread.run(Thread.java:745)

我的问题是,我用粗体表示的这句话说我没有这个存储库:org.springframework.web.servlet.DispatcherServlet在我的项目中。但是,我确信它可以在我的依赖项中看到。文件spring-webmvc.4.3.8.Release.jar在预期的文件夹(WEB-INF / lib)中可见,它包含一个名为DispatcherServlet的类文件.class可以在netbeans的项目窗口中访问。

我还检查了POM文件,我将这些文件和其他两个弹簧网络jar文件声明为依赖项:

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.3.8.RELEASE</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <!-- Set this to the respective version -->
            <version>4.3.8.RELEASE</version>
            <scope>provided</scope>
            <type>jar</type>
        </dependency>

那么,我在这里做错了什么吗?由于TomCat没有提供任何进一步的信息来确切地说明找不到什么,我看到的唯一问题就是这个。

提前致谢:)

1 个答案:

答案 0 :(得分:0)

您可以检查您的人工制品(战争)中是否存在库。如果pom.xml配置不正确,那么可能缺少某些库。