在我第一次学习servlet的时候,运行Tomcat时,出现了以下的报错:
D:apache-tomcat-7.0.100incatalina.bat run [2020-02-27 06:13:44,776] Artifact Java_Web_Servlet01:war: Waiting for server connection to start artifact deployment... Using CATALINA_BASE: "C:UsersAdministrator.IntelliJIdea2019.2system omcatUnnamed_Demo05" Using CATALINA_HOME: "D:apache-tomcat-7.0.100" Using CATALINA_TMPDIR: "D:apache-tomcat-7.0.100 emp" Using JRE_HOME: "E:jdk1.8.0_181" Using CLASSPATH: "D:apache-tomcat-7.0.100inootstrap.jar;D:apache-tomcat-7.0.100in omcat-juli.jar" 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server.服务器版本: Apache Tomcat/7.0.100 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 服务器构建: Feb 11 2020 08:31:12 UTC 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 服务器版本号(:7.0.100.0 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS Name: Windows 7 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS.版本: 6.1 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 架构: amd64 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Java 环境变量: E:jdk1.8.0_181jre 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM 版本: 1.8.0_181-b13 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM.供应商: Oracle Corporation 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_BASE: C:UsersAdministrator.IntelliJIdea2019.2system omcatUnnamed_Demo05 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_HOME: D:apache-tomcat-7.0.100 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Djava.util.logging.config.file=C:UsersAdministrator.IntelliJIdea2019.2system omcatUnnamed_Demo05conflogging.properties 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcom.sun.management.jmxremote= 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcom.sun.management.jmxremote.port=1099 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcom.sun.management.jmxremote.ssl=false 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcom.sun.management.jmxremote.password.file=C:UsersAdministrator.IntelliJIdea2019.2system omcatUnnamed_Demo05jmxremote.password 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcom.sun.management.jmxremote.access.file=C:UsersAdministrator.IntelliJIdea2019.2system omcatUnnamed_Demo05jmxremote.access 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Djava.rmi.server.hostname=127.0.0.1 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dignore.endorsed.dirs= 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcatalina.base=C:UsersAdministrator.IntelliJIdea2019.2system omcatUnnamed_Demo05 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcatalina.home=D:apache-tomcat-7.0.100 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Djava.io.tmpdir=D:apache-tomcat-7.0.100 emp 二月 27, 2020 6:13:46 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0]. 二月 27, 2020 6:13:46 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 二月 27, 2020 6:13:46 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized [OpenSSL 1.1.1c 28 May 2019] 二月 27, 2020 6:13:46 下午 org.apache.coyote.AbstractProtocol init 信息: 初始化协议处理器 ["http-apr-8080"] 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 802 ms 二月 27, 2020 6:13:46 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service [Catalina] 二月 27, 2020 6:13:46 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.100 二月 27, 2020 6:13:46 下午 org.apache.coyote.AbstractProtocol start 信息: 开始协议处理句柄["http-apr-8080"] 二月 27, 2020 6:13:46 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 154 ms Connected to server [2020-02-27 06:13:46,921] Artifact Java_Web_Servlet01:war: Artifact is being deployed, please wait... 二月 27, 2020 6:13:47 下午 org.apache.catalina.loader.WebappClassLoaderBase validateJarFile 信息: validateJarFile(D:apache-tomcat-7.0.100webappss1WEB-INFlibjavax.servlet-api-4.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class 二月 27, 2020 6:13:47 下午 org.apache.catalina.deploy.WebXml setVersion 警告: Unknown version string [4.0]. Default version will be used. 二月 27, 2020 6:13:47 下午 org.apache.catalina.core.ContainerBase addChildInternal 严重: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/s1]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1016) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:992) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:639) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:303) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:633) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:577) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:303) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> [hello] in servlet mapping at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3511) at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3486) at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1452) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1316) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:888) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5606) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 44 more 二月 27, 2020 6:13:47 下午 org.apache.tomcat.util.modeler.BaseModelMBean invoke 严重: Exception invoking method manageApp java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/s1]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1020) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:992) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:639) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:303) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:633) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:577) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:303) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) [2020-02-27 06:13:47,456] Artifact Java_Web_Servlet01:war: Error during artifact deployment. See server log for details. at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 二月 27, 2020 6:13:47 下午 org.apache.tomcat.util.modeler.BaseModelMBean invoke 严重: Exception invoking method createStandardContext javax.management.RuntimeOperationsException: Exception invoking method manageApp at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:311) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:633) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:577) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:303) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/s1]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1020) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:992) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:639) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:303) ... 35 more 二月 27, 2020 6:13:56 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: 把web 应用程序部署到目录 [D:apache-tomcat-7.0.100webappsmanager] 二月 27, 2020 6:13:56 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deployment of web application directory [D:apache-tomcat-7.0.100webappsmanager] has finished in [286] ms
经过几番检查后,终于发现,我的请求路径少了一条斜杠
将<url-pattern>hello</url-pattern> 改为: <ulr-pattern>/hello</url-pattern> 即可
可能初学servlet的同学也会遇到相类似的情况,因为观察不细致,导致耗费大量的时间去检查和百度搜索,因此我在这里分享一下出现这个错误的原因之一,也是我初学servlet时所遇到的问题,希望能为出现同样问题的小伙伴提供帮助。
这也告诉我们了一点就是在写代码的时候,决不能放过一丝细节,否则代码写了一大堆,一运行就报错(心态肯定崩溃了)。
加油
时间:2020-03-29 11:11:48