严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
处理方法:
1、核对lib包
commons-fileupload-1.2.1.jar,
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.16.jar
ognl-3.0.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar)
注意2.1以前是没有commons-fileupload-1.2.1.jar,
2、如果struts2版本是2.1以前
web.xml配置过滤器的时候应该是这样:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
如果struts2 版本是2.1以上
web.xml配置
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
3、在使用struts-2.2.1时,需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [applicationContext.xml] is invalid;
nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
原来的spring配置文件头是:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
改成:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
问题解决。
1、避免出现log4j的警告信息
在classes文件夹下建立log4j.properties,内容如下:
# Configure logging for testing: optionally with log file
log4j.rootLogger=WARN, stdout
# log4j.rootLogger=WARN, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=target/spring.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
2、如果已设计数据库表中的主键,则不用在映射文件中在对应属性中加入
<generator class="native" /></generator>
1、在eclipse中启动tomcat时出现Setting property 'source' to 'org.eclipse.jst.jee.server:你的站点名' did not find a matching property错误
警告的原因是Tomcat6.0的server.xml的context节点中不支持source属性.
解决办法:
1)、在server控制台内,在服务器上点右键--属性
2)、general选项卡中点switch location
这时,location变为:/servers/tomcat6.0 server at localhost.server
3)、在project explore中找到tomcat项目--Tomcat v6.0 Server at localhost.server 这个文件 ,双击打开
4)、在最下面的server option里选中publis module context to separate xml file.保存。(保存时要先停止服务器)
2、Tomcat启动的时候出现下面这样的提示:
2008-3-15 14:24:12 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: D:\Java\jdk1.5.0_05\bin;.;C:\WINDOWS\system32;C:\WINDOWS;d:\ruby\bin;.;..;D:\Java\jrockit-R26.0.0-jdk
.......
实际这是建议使用apache的apr。
如果想使用apr的话, 实际操作很简单,
下载 http://tomcat.heanet.ie/native/1.1.12/binaries/win32/tcnative-1.dll
将这个文件复制到C:\WINDOWS\system32\,.也可以放在Tomcat安装路径下的bin目录里
然后重新启动tomcat,就会发现tomcat 的控制台信息为:
2008-3-15 14:33:49 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.12.
2008-3-15 14:33:49 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], ra
ndom [true].