java.lang.ClassNotFoundException: org.apache.strut

This is a common error message for a new Struts2 developer. Many Struts 2 related websites have been reported this problem. Overall, when we see a ClassNotFoundException, we should have a reflection that it is very possible that the build path is wrong somewhere.

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

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.(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

The problem is caused by the class path.

After you create a dynamic web project under eclipse, you should have the following directory underProject Explorer view.

You may Add External Jars under Java Build Path window like the following:

This works for regular Java project, but does not work for Struts2 web project.

The solution is to simply copy the jar files required to the "lib" directory, then the error message will be gone. 

(remove all jars from the class path if you added them before)

Note: Actually, when the error message is something about ClassNotFoundException, we should think in the direction of build path is not correct. Also, different kinds of Java project may use different way to configure build path, e.g., an eclipse plug-in project have to use plug-in to add some library to it.

时间: 2024-10-11 11:36:48

java.lang.ClassNotFoundException: org.apache.strut的相关文章

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFil

项目启动时报错:java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2的jar包版本号为2.1.8,所以类名是没有错误的,而jar包确实加入进去了.jar包加入的方式是通过user library. 问题解决的办法是:将jar包拷贝到WEB-INF下lib文件夹目录,重新启动tomcat问题解决. ================

Caused by: java.lang.ClassNotFoundException: org.apache.shiro.spring.LifecycleBeanPostProcessor

1.错误描述 Caused by: java.lang.ClassNotFoundException: org.apache.shiro.spring.LifecycleBeanPostProcessor at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRe

java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource解决方法

java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource解决方法 只需把这三个commons-pool.jar.commons-dbcp-1.2.2.jar和commons-collections-3.2.jar包加入到lib里即可解决.这三个包在你本地的tomcat下的lib里,直接buildpath导入就行了,不过有时导包不一定好使,是因为工程lib下的包跟tomcat下的包重复了,导致异常错误如: o

java.lang.ClassNotFoundException: org.apache.commons.dbutils.QueryRunner

七月 28, 2017 11:06:33 下午 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet [com.itheima.transfer.web.TransferServlet] in context with path [/WEB19] threw exception [Servlet execution threw an exception] with root ca

Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils

1.错误描述 警告: Could not create JarEntryRevision for [jar:file:/D:/MyEclipse/apache-tomcat-7.0.53/webapps/FirstSSH/WEB-INF/lib/struts2-core-2.3.16.3.jar]! java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils at com.opensymphony.xwork2.util.fs.

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

1.错误描述 2014-7-10 23:12:23 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils at com.opensymphony.xwork2.config.providers.XmlConfigurationProv

java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException

遇到这种问题是因为jar包引入不全,完整的应该包含: commons-beanutils-1.8.3.jar commons-lang-2.5.jar ezmorph-1.0.6.jar json-lib-2.3-jdk15.jar 但是又出现如下问题: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 导入commons-logging-1.1.1.jar 又出现如下问题: java.lang.NoC

ssh整合启动tomcat报java.lang.ClassNotFoundException: org.apache.commons.lang.xwork.StringUtils

今天搭建了一个ssh项目环境,整合后,访问项目首页,登录不进去,控制台报错,后来调试代码后,在获取数据库数据后,返回到action时,又进入了action导致死循环,其实这里是两个问题,控制台报错如下: 2015-4-27 20:57:56 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet default threw exceptionjava.lang.ClassNotFo

已解决:java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.com.yourproject.test_jsp

同事遇到了一个问题,开始项目运行的好好的,过了一段时间再访问页面会报出如下错误信息(只贴了部分), 这是为啥呢,可能是由于servlet-api版本jar包重复导致的,他项目本身使用了servlet-api(pom.xml中引用), 通过eclipse部署tomcat,tomcat中也包含了servlet-api.jar,而且这两个jar包版本不一致.换成版本一致的重新部署之即可, java.lang.ClassNotFoundException: org.apache.jsp.WEB_002d