IDEA启动Tomcat时报java.lang.IllegalStateException: Error starting child

今天刚刚开始学习使用idea时,在网上查了资料后,写了一个简单的Servlet做测试,结果出现:

[2019-01-13 01:30:39,745] Artifact testidea:war exploded: Artifact is being deployed, please wait...
13-Jan-2019 13:30:40.147 涓ラ噸 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method manageApp
 java.lang.IllegalStateException: Error starting child
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:716)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1729)
	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:287)
	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:457)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406)
	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:287)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	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 javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)

检查了web.xml文件和tomcat配置以及jar包发现一切正常,百度发现没有过这种错误。。。可能因为自己太菜了犯这种比较低级的错误。经过一番周折才发现原因是web.xml中配置了servlet

	<servlet>
        <servlet-name>TestServletservlet-name>
        <servlet-class>com.caohuimin.servlet.TestServletservlet-class>
    servlet>
    <servlet-mapping>
        <servlet-name>TestServletservlet-name>
        <url-pattern>/testurl-pattern>
    servlet-mapping>

同时Servlet测试代码前加了注解@WebServlet("/test"),当这两者同时存在时就会报这种错误,删除一种即可。
如果还没有解决的话,可以看一下有没有引入多个版本的同一类jar包,如:
在这里插入图片描述
删除一种即可。
如果还没有解决的话,建议查看一下与之前正常运行时候的版本有哪些地方做了修改,检查配置文件是否有问题、jar包导入是否有问题。

你可能感兴趣的:(工具使用,错误和异常)