首页 > 代码库 > Eclipse中启动Tomcat报错(struts2应用开发)

Eclipse中启动Tomcat报错(struts2应用开发)

今天开始接触struts2,完成应用后一大堆报错,其实通过【项目】->【右键】->【build path】->【configure build path】改相应的配置就能够改正所有错误了。很多错误可以通过网上搜素改正。通过纠正这些错误也有助于你更好的理解开发strut2的一些配置。

解决了所有错误后,启动tomcat服务器网页总是报错。这时候可以去看看Console的一些信息,会发现以下错误:

严重: Exception starting filter struts2java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:211)    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4594)    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5201)    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)    at java.util.concurrent.FutureTask.run(FutureTask.java:266)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)    at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1320)    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1173)    ... 20 more

我用的是struts-2.3版本的库,当时在项目中导入了一些常用的库,如下:

很明显,报错是因为缺少库引起的,我在struts2的文件中找到相应的库commons-lang3-3.1.jar,然后导入,OK了。

Eclipse中启动Tomcat报错(struts2应用开发)