sun176976547
sun176976547
2011-01-06 00:16

Struts2初次配置启动tomcat出错

  • struts

开发环境:
Eclipse Java EE IDE for Web Developers.

Version: Helios Service Release 1
Build id: 20100917-0705

Tomcat 6.x log:
[code="txt"]
2011-1-6 0:04:30 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Struts2Demo' did not find a matching property.
2011-1-6 0:04:30 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_02\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.6.0_02/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0_02/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_02/bin/../jre/lib/i386;C:\Program Files\PC Connectivity Solution\;C:\Program Files\Java\jdk1.6.0_02\bin;C:\Program Files\Java\jre1.6.0_02;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\EmEditor;C:\Program Files\TortoiseSVN\bin
2011-1-6 0:04:30 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2011-1-6 0:04:30 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 759 ms
2011-1-6 0:04:30 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-1-6 0:04:30 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.16
2011-1-6 0:04:30 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:249)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2011-1-6 0:04:30 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2011-1-6 0:04:30 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2Demo] startup failed due to previous errors
2011-1-6 0:04:30 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-1-6 0:04:30 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-1-6 0:04:30 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31 config=null
2011-1-6 0:04:30 org.apache.catalina.startup.Catalina start
信息: Server startup in 622 ms
[/code]

web.xml如下:
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>

Struts2Demo

<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>

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


[/code]

在xml中右键点击:org.apache.struts2.dispatcher.FilterDispatcher,可以进入FilterDispatcher类。

我在网上搜了下,提供的解决方案有:
1、导入commons-fileupload.jar和commons-io.jar包

2、将tomcat及jdk版本更新到struts2的需求,即5.5及1.5

3、添加struts2开发所需完整jar包

4、检查web.xml及struts.xml是否书写错误

5、将struts2相关包手动添加到classpath中
除了5我都试过,没有问题。
引入的jar包,见下图:
[img]http://dl.iteye.com/upload/attachment/383348/cc12094e-5796-379c-b2f8-2facfb753bc6.jpg[/img]
PS:我十分想将红圈里的那俩东西删掉,但是也不知道怎么搞。我是建立的Dynamic Web Project,建完之后就带着了,删不掉。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

15条回答

为你推荐