找不到org.apache.commons.lang.StringUtils 这个类

最近在学习SSH2,在Spring和hibernate集成成功后,与Struts2进行集成时,在一切工作完成后启动tomcat时,出现了一个严重警告,也可以说是错误,因为虽然tomcat是启动成功了,但相应的项目还是运行不了。

现在把错误的详细信息粘贴出来,其中重点部分用红色凸显:

信息: Deploying web application directory SSH2
2011-12-8 17:22:31 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2011-12-8 17:22:40 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:198)
 at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
 at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
 at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380)
 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424)
 at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
 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.addChildInternal(ContainerBase.java:799)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
 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)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
 at java.lang.ClassLoader.loadClassInternal(Unknown Source)
 ... 35 more
2011-12-8 17:22:40 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2011-12-8 17:22:40 org.apache.catalina.core.StandardContext start
严重: Context [/SSH2] startup failed due to previous errors
2011-12-8 17:22:40 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2011-12-8 17:22:40 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/SSH2] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2011-12-8 17:22:40 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/SSH2] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
2011-12-8 17:22:41 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-12-8 17:22:41 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-12-8 17:22:41 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47  config=null
2011-12-8 17:22:41 org.apache.catalina.startup.Catalina start
信息: Server startup in 16304 ms

经过多方查找,最后终于把问题解决了,由红色显示部分可以看出问题出在一个找不到的类身上,那么为什么会找不到org.apache.commons.lang.StringUtils 这个类呢?这个类是在那个包中呢?根据类的名字,我们大概可以猜测出,而且经过验证它也确实位于commons-lang.jar,既然找到了问题所在,那么我们只需把这个jar包复制到/%/lib目录下即可了。我复制的是Struts2.2.3目录下的commons-lang-2.5.jar,经过验证,问题解决!!
 

你可能感兴趣的:(找不到org.apache.commons.lang.StringUtils 这个类)