Idea 开发微信java基本功能 tomcat无法启动

项目使用了maven,主要是xml的解析与生成,代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>

<artifactId>weChat</artifactId>

<version>1.0-SNAPSHOT</version>

<dependencies>

<dependency>

<groupId>dom4j</groupId>

<artifactId>dom4j</artifactId>

<version>1.6</version>

</dependency>

<dependency>

<groupId>com.thoughtworks.xstream</groupId>

<artifactId>xstream</artifactId>

<version>1.4.8</version>

</dependency>

</dependencies>

</project>

web.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

version="3.1">

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<servlet>

<servlet-name>weChatServlet</servlet-name>

<servlet-class>com.xc.servlet.WexinServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>weChatServlet</servlet-name>

<url-pattern>/weChat</url-pattern>

</servlet-mapping>

</web-app>

运行在tomcat报错如下:

Connected to server

[2015-09-07 11:09:57,668] Artifact weChat:war exploded: Artifact is being deployed, please wait...

九月 07, 2015 11:09:58 下午 org.apache.catalina.deploy.WebXml setVersion

警告: Unknown version string [3.1]. Default version will be used.

九月 07, 2015 11:09:58 下午 org.apache.catalina.core.ContainerBase addChildInternal

严重: ContainerBase.addChild: start:

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

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:652)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

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:618)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

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:1487)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)

at sun.rmi.transport.Transport$1.run(Transport.java:177)

at sun.rmi.transport.Transport$1.run(Transport.java:174)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:173)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)

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:724)

Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException

at java.lang.Class.getDeclaredFields0(Native Method)

at java.lang.Class.privateGetDeclaredFields(Class.java:2387)

at java.lang.Class.getDeclaredFields(Class.java:1796)

at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)

at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)

at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:139)

at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)

at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:415)

at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:892)

at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5419)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 40 more

Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1722)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573)

... 54 more

九月 07, 2015 11:09:58 下午 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[]]

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:905)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

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:618)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

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:1487)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)

at sun.rmi.transport.Transport$1.run(Transport.java:177)

at sun.rmi.transport.Transport$1.run(Transport.java:174)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:173)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)

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:724)

九月 07, 2015 11:09:58 下午 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:309)

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:618)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

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:1487)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[2015-09-07 11:09:58,639] Artifact weChat:war exploded: Error during artifact deployment. See server log for details.

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)

at sun.rmi.transport.Transport$1.run(Transport.java:177)

at sun.rmi.transport.Transport$1.run(Transport.java:174)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:173)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)

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:724)

Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:905)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

... 31 more

九月 07, 2015 11:10:07 下午 org.apache.catalina.startup.HostConfig deployDirectory

信息: Deploying web application directory D:\apache-tomcat-7.0.63\webapps\manager

九月 07, 2015 11:10:07 下午 org.apache.catalina.startup.HostConfig deployDirectory

信息: Deployment of web application directory D:\apache-tomcat-7.0.63\webapps\manager has finished in 267 ms

Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException提示是找不到这个类,但是在maven中有这个包?何解?
XML解析相关代码:

public class MessageUtil {

/**

* 将request流xml 转换为Map类型

*

* @param request

* @return

* @throws IOException

* @throws DocumentException

*/

public static Map<String, String> xmlToMap(HttpServletRequest request) throws IOException, DocumentException {

Map<String, String> map = new HashMap<String, String>();

SAXReader reader = new SAXReader();

InputStream ins = request.getInputStream();

Document doc = reader.read(ins);

Element root = doc.getRootElement();

List<Element> list = root.elements();

for (Element e : list) {

map.put(e.getName(), e.getText());

}

ins.close();

return map;

}

/**

* 将对象转换为XML

* @param textMessage

* @return

*/

public static String textMessageToXml(TextMessage textMessage) {

XStream xstream = new XStream();

xstream.alias("xml",textMessage.getClass());

return xstream.toXML(textMessage);

}

}

回答:

看一下Maven的Dependency是否被导入到Artifact中了,没有就加进去
图片描述

回答:

1,rebuild project试下,然后mvn clean package 确保相应的包下载下来了
2,在idea里直接ctrl+N搜索DocumentException,如果正常找到的话,会提示所在的jar包的.另外在idea的project的dependencies视图下也能看到项目加载了哪些依赖的
3,还有一种可能,启动tomcat启动找不到对应类,需要看下自身的tomcat的lib下是否有重复的类名导致的加载顺序问题引起的.

以上是 Idea 开发微信java基本功能 tomcat无法启动 的全部内容, 来源链接: utcz.com/p/175788.html

回到顶部