Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher

Tags:

java

struts2

log when start the tomcat

Apr 28, 2011 10:52:57 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\software\jdk1.5.0_06\bin;.;C:\WINDOWS\system32;C:\WINDOWS;D:/software/jdk1.5.0_06/bin/../jre/bin/client;D:/software/jdk1.5.0_06/bin/../jre/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\TortoiseSVN\bin.;D:\software\jdk1.5.0_06\bin;D:\software\Ant 1.7\bin;D:\software\Axis2-1.5.4\axis2-1.5.4-bin\axis2-1.5.4\bin;C:\Program Files\IDM Computer Solutions\UltraEdit\
Apr 28, 2011 10:52:58 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsHelloWorld' did not find a matching property.
Apr 28, 2011 10:52:58 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsHelloWorld1' did not find a matching property.
Apr 28, 2011 10:53:00 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Apr 28, 2011 10:53:00 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3657 ms
Apr 28, 2011 10:53:00 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 28, 2011 10:53:00 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
Apr 28, 2011 10:53:01 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:269)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4071)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4725)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    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:585)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Apr 28, 2011 10:53:01 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Apr 28, 2011 10:53:01 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/StrutsHelloWorld1] startup failed due to previous errors
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.
Apr 28, 2011 10:53:05 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Apr 28, 2011 10:53:05 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Apr 28, 2011 10:53:05 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/46  config=null
Apr 28, 2011 10:53:05 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4951 ms
like image 936
user714698 Avatar asked Apr 28 '11 05:04

user714698


3 Answers

If you have...

  1. included all necessary jars
  2. Configured build path correctly
  3. added them all in deployment assembly
    Correctly.

then also you getting "java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher" error then you could be doing below things wrong.

solution:

check your struts2-core-x.x.jar version.

-->if it is struts2-core-2.5.jar then change your filter class tag value in web.xml to

<filter-class>
     org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
  </filter-class>

-->if it is struts2-core-2.1.3.jar then change your filter class tag value in web.xml to

<filter-class>
     org.apache.struts2.dispatcher.FilterDispatcher
  </filter-class>

FilterDispatcher is deprecated since Struts 2.1.3. If you are working with older versions then user above solution.

-->if it is struts2-core-2.3.X.jar then change your filter class tag value in web.xml to

<filter-class> 
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>

Reason behind all this is struts 2 controllers are placed in different location in different version of struts2-core jar and some time they are called by different name as you can see in 2.1.3.

Thank you,

like image 130
shiv Avatar answered Oct 23 '22 11:10

shiv


Struts2 requires a certain number of jar files before executing your programs. Make sure you have these included in your editing tools:

commons-logging-x.x.jar
freemarker-x.x.jar
xwork-x.x.jar
struts2-core-x.x.jar
ognl-x.x.jar

It would be likely that the common-logging jar is missing.

Check out the struts2 lib files to get these jars. :)

You may wanna check this url out as well:

http://www.mkyong.com/struts2/difference-between-struts-2-filterdispatcher-and-strutsprepareandexecutefilter/

like image 45
prog rice bowl Avatar answered Oct 23 '22 12:10

prog rice bowl


If you are using Eclipse then adding the required libraries just in Java Build Path will not work. You have to again add those libraries in Deployment Assembly. Right Click On Project>> Properties >> select Deployment Assemlby . Add required Java Build Path entries by clicking on Add.. button.

like image 1
dnsh Avatar answered Oct 23 '22 11:10

dnsh