加班ing,组长给了个现成的jee项目,导入eclipse后。启动tomcat报错,报错日志如下(由于报错信息太多,此处只截取一个样例。其他报错信息均为找不到java/util/List.class等基本java类):
1 java.io.FileNotFoundException: /home/monkey/worksrv/apache-tomcat-6.0.41/webapps/PriceSystem/WEB-INF/classes/com/opensymphony/xwork2/ActionSupport.class (No such file or directory) 2 at java.io.FileInputStream.open(Native Method) 3 at java.io.FileInputStream.(FileInputStream.java:140) 4 at com.opensymphony.xwork2.util.classloader.FileResourceStore.read(FileResourceStore.java:44) 5 at com.opensymphony.xwork2.util.classloader.ResourceStoreClassLoader.fastFindClass(ResourceStoreClassLoader.java:42) 6 at com.opensymphony.xwork2.util.classloader.ResourceStoreClassLoader.loadClass(ResourceStoreClassLoader.java:57) 7 at java.lang.ClassLoader.loadClass(ClassLoader.java:268) 8 at java.lang.ClassLoader.defineClass1(Native Method) 9 at java.lang.ClassLoader.defineClass(ClassLoader.java:643)10 at java.lang.ClassLoader.defineClass(ClassLoader.java:489)11 at com.opensymphony.xwork2.util.classloader.ResourceStoreClassLoader.fastFindClass(ResourceStoreClassLoader.java:45)12 at com.opensymphony.xwork2.util.classloader.ResourceStoreClassLoader.loadClass(ResourceStoreClassLoader.java:57)13 at java.lang.ClassLoader.loadClass(ClassLoader.java:268)14 at com.opensymphony.xwork2.util.classloader.ReloadingClassLoader.loadClass(ReloadingClassLoader.java:144)15 at com.opensymphony.xwork2.util.finder.ClassLoaderInterfaceDelegate.loadClass(ClassLoaderInterfaceDelegate.java:34)16 at com.opensymphony.xwork2.util.finder.ClassFinder$ClassInfo.get(ClassFinder.java:562)17 at com.opensymphony.xwork2.util.finder.ClassFinder.findClasses(ClassFinder.java:343)18 at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:393)19 at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:347)20 at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)21 at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:268)22 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)23 at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)24 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)25 at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)26 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)27 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:298)28 at org.apache.catalina.core.ApplicationFilterConfig. (ApplicationFilterConfig.java:119)29 at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4076)30 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4730)31 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)32 at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)33 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)34 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)35 at org.apache.catalina.core.StandardService.start(StandardService.java:525)36 at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)37 at org.apache.catalina.startup.Catalina.start(Catalina.java:595)38 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)39 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)40 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)41 at java.lang.reflect.Method.invoke(Method.java:622)42 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)43 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
即连最基本的jar包导入的类都找不到。
到网上搜了N多信息,最终在一个不起眼的iteye中找到了问答(也只是问答,具体原理没说)。解决方案如下:
在struts.xml配置文件中,找到如下配置项:
将该配置项的属性value设为false,即可解决上述的报错。
-----------------------------------------暂时分割线-----------------------------------------
在另一篇blog中摸索了这么一条信息:
导致这个问题可能的原因:
1. windows操作系统下,tomcat安装目录中带空格(笔者的系统是ubuntu,将tomcat移至无空格目录中,同样报错)
2. struts版本问题。国外BBS上讨论的这个问题,低版本的bug,更新至高版本就没有问题。
由于时间问题,笔者没有做详细验证,在此处做一下记录以警示。
注:上述信息都是从网上查看了N多blog获得的信息,笔者尊重作者原创,若作者强调原创,请告知笔者。谢谢!