Struts2运行错误:Error filterStart

2022-09-14 10:57:11 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

困扰我近10多天的问题,让我在框架功力修炼上几乎停滞不前,今天问题被KO,小小的高兴下。

纯洁的web.xml文件

代码语言:javascript复制
 <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>

我的日志localhost.2012-08-24.log文件

2012-8-24 10:10:15org.apache.catalina.core.ApplicationContext log

信息: ContextListener: contextInitialized()

2012-8-24 10:10:15 org.apache.catalina.core.ApplicationContextlog

信息: SessionListener: contextInitialized()

2012-8-24 10:10:16org.apache.catalina.core.StandardContext filterStart

严重: Exception starting filter struts2

java.lang.NullPointerException

atcom.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209)

atcom.opensymphony.xwork2.util.FileManager.fileNeedsReloading(FileManager.java:60)

atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:325)

atorg.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:168)

atcom.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:220)

atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:61)

atorg.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:774)

atorg.apache.struts2.dispatcher.ng.InitOperations.initStaticContentLoader(InitOperations.java:77)

atorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:49)

atorg.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)

atorg.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)

atorg.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)

atorg.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)

atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4726)

atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)

atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)

atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)

atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)

atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)

atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)

atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)

atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)

atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)

atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)

atorg.apache.catalina.core.StandardHost.start(StandardHost.java:840)

atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)

atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

atorg.apache.catalina.core.StandardService.start(StandardService.java:525)

atorg.apache.catalina.core.StandardServer.start(StandardServer.java:754)

atorg.apache.catalina.startup.Catalina.start(Catalina.java:595)

atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

atsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

atjava.lang.reflect.Method.invoke(Unknown Source)

atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Tomcat后台报错:

严重: Error filterStart

2012-8-24 10:10:16org.apache.catalina.core.StandardContext start

严重: Context [/Struts2_0400_Path] startupfailed due to previous errors

2012-8-24 10:10:16org.apache.catalina.loader.WebappClassLoader clearThreadLocal

Map

严重: The web application [/Struts2_0400_Path]created a ThreadLocal with key of

type[com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony

.xwork2.inject.ContainerImpl$10@166c114]) and a value of type[java.lang.Object[

]] (value [[Ljava.lang.Object;@10e1513])but failed to remove it when the web ap

plication was stopped. This is very likely tocreate a memory leak.

2012-8-24 10:10:16org.apache.catalina.loader.WebappClassLoader clearThreadLocal

Map

严重: The web application [/Struts2_0400_Path]created a ThreadLocal with key of

type[com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony

.xwork2.inject.ContainerImpl$10@509df8]) anda value of type [java.lang.Object[]

] (value [[Ljava.lang.Object;@b31a7c])but failed to remove it when the web appl

ication was stopped. This is very likely tocreate a memory leak.

2012-8-24 10:10:17org.apache.coyote.http11.Http11AprProtocol start

信息: Starting Coyote HTTP/1.1 on http-80

2012-8-24 10:10:17org.apache.coyote.ajp.AjpAprProtocol start

信息: Starting Coyote AJP/1.3 on ajp-8009

2012-8-24 10:10:17org.apache.catalina.startup.Catalina start

信息: Server startup in 2835 ms

解决方案:

1、你把核心的filter改成<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 试试看看是否能够正常启动

2、恩,问题解决了,是因为我用的struts2.3.1版本,缺少一个jar包common-lang,导入就好 了,不过纠结一整天算是找到了一个方法,就是在tomcat控制台看不到结果的时候,去tomcat/logs文件夹下看日志文件,结果发现

java.lang.NoClassDefFoundError:org/apache/commons/lang/StringUtils StringUtils 在common-lang包中

3、

估计是包引用的事情 在apache网站下载下来的包可能有问题 你找个能运行的例子,把你现在对应的lib下的包换下

4、

tomcat6.0 jdk1.6下 项目中要放一下jar包

struts2-core-2.2.1.

ar xwork-core-2.2.1.jar

ognl-3.0.jar

javassist-3.7.ga.jar

freemarker-2.3.16.jar

commons-io-1.3.2.jar

commons-fileupload-1.2.1.jar

commons-logging-1.0.4.jar

其它解决方案:

1、试着把tomat/server/lib目录下的commons-digester.jar,commons-beanutils.jar拷贝到common/lib/目录 --经测试不行,tomcat5.5对应目录下根本没有对应的包。 2、有个文章说tomcat里的bug,没有实现javax.servlet.Filter的Filter会报这样的错误,看来tomcat在启动就初始化Filter实例,但是在filter中又没有看到那段代码没有实现Filter,或者有代码在启动时没有实例化。--没发现问题。

**************************************** 问题解决了,将web.xml文件中filter配置删除重新写了一遍,然后将tomcatcommonlib下的servlet-api.jar拷贝到tomcatserverlib下,重新启动后就好了,也不知道与这个包有没有关系!

摘录总结下: 1、如果以后出现tomcat 严重: Error filterStart 错误,一般原因为:1、xml配置失误 2、filter中某段代码未实例化(这个情况是出现最多的,要仔细检查) 3、试着把tomat/server/lib目录下的commons-digester.jar,commons-beanutils.jar拷贝到common/lib/目录,有些包在部署是没有被包含

开源中国论坛终曲解答:

这是tomcat6.0之后的内存检查机制,理论上换5.5重新部署应该没问题的,或者试试在server.xml里注释掉下面这句

<ListenerclassName=”org.apache.catalina.core.JreMemoryLeakPreventionListener”/>

尝试方案三:

D:ProgramFilesTomcat6有空格

重装Tomcat、MyEclipse,消除安装路径空格问题:

D:ProgramFilesTomcat6

亲,上次关于struts2的tomcat后台报错问题(http://topic.csdn.net/u/20120824/10/b04b46a5-eb73-4c31-b999-f1242f26f3a8.html)已解决:一怒之下,重新装MyEclipse/Tomcat6,发现……竟然可以了。估计是tomcat安装路径有空格问题、或者:链接:http://www.oschina.net/question/726248_67707

问题解决后,重新部署、访问 访问路径:http://localhost/Struts2_0100_Introduction

Struts Problem Report

Struts has detected an unhandled exception:

Messages:

· There is no Action mapped for namespace / and action name .

解决:

访问路径、NameSpace、Action命名/路径问题:

访问路径:http://localhost/Struts2_0100_Introduction/hell正确访问 至此,Game Over!!!

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/157250.html原文链接:https://javaforall.cn

0 人点赞