引起:java.lang.ClassNotFoundException:org.apache.struts2.StrutsTestCase

时间:2013-10-14 09:29:52

标签: struts2 junit4

我是新手Struts2。 运行单元测试时出现此错误。

消息:SEVERE:加载类时出错[com.ecs.local.register.action.RegisterActionTest] java.lang.NoClassDefFoundError:org / apache / struts2 / StrutsTestCase

但是我的项目已经包含了Junit和StrutsTestCase。希望你的帮助。非常感谢你!

   Oct 14, 2013 4:11:09 PM 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: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_40\bin;C:\Program Files\apache-maven-3.1.0\bin;.
Oct 14, 2013 4:11:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:test' did not find a matching property.
Oct 14, 2013 4:11:09 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 14, 2013 4:11:09 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 550 ms
Oct 14, 2013 4:11:09 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 14, 2013 4:11:09 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-default.xml]
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-plugin.xml]
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts.xml]
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.ObjectFactory)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.FileManagerFactory)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.XWorkConverter)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.CollectionConverter)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.ArrayConverter)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.DateConverter)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.NumberConverter)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.StringConverter)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionFileProcessor)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.TypeConverterCreator)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.TypeConverterHolder)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.TextProvider)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.LocaleProvider)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.ActionProxyFactory)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ObjectTypeDeterminer)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.mapper.ActionMapper)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (jakarta) for (org.apache.struts2.dispatcher.multipart.MultiPartRequest)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.views.freemarker.FreemarkerManager)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.components.UrlRenderer)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.validator.ActionValidatorManager)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.ValueStackFactory)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionProvider)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionContextFactory)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.PatternMatcher)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.StaticContentLoader)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.UnknownHandlerManager)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.views.util.UrlHelper)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.TextParser)
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Overriding property struts.i18n.reload - old value: false new value: true
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Overriding property struts.configuration.xml.reload - old value: false new value: true
Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Unable to read class [com.ecs.local.register.action.RegisterActionTest]
Could not load org/apache/struts2/StrutsTestCase.class - [unknown location]
    at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:722)
    at com.opensymphony.xwork2.util.finder.ClassFinder.access$400(ClassFinder.java:70)
    at com.opensymphony.xwork2.util.finder.ClassFinder$InfoBuildingVisitor.extractSuperInterfaces(ClassFinder.java:767)
    at com.opensymphony.xwork2.util.finder.ClassFinder$InfoBuildingVisitor.visit(ClassFinder.java:754)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:717)
    at com.opensymphony.xwork2.util.finder.ClassFinder.<init>(ClassFinder.java:112)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:390)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:347)
    at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:260)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:473)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    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:424)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(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)

Oct 14, 2013 4:11:10 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Error loading class [com.ecs.local.register.action.RegisterActionTest]
java.lang.NoClassDefFoundError: org/apache/struts2/StrutsTestCase
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at com.opensymphony.xwork2.util.finder.ClassLoaderInterfaceDelegate.loadClass(ClassLoaderInterfaceDelegate.java:34)
    at com.opensymphony.xwork2.util.finder.ClassFinder$ClassInfo.get(ClassFinder.java:562)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder$3.test(PackageBasedActionConfigBuilder.java:622)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder$3.test(PackageBasedActionConfigBuilder.java:609)
    at com.opensymphony.xwork2.util.finder.ClassFinder.findClasses(ClassFinder.java:342)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:393)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:347)
    at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:260)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:473)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    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:424)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(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)
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.StrutsTestCase
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 39 more

Oct 14, 2013 4:11:10 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 14, 2013 4:11:10 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Oct 14, 2013 4:11:10 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/32  config=null
Oct 14, 2013 4:11:10 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1248 ms

1 个答案:

答案 0 :(得分:0)

谢谢你们每个人!我已经解决了我的问题。因为我是新手,所以我不知道如何使用单元测试,因此,当app在服务器上运行时,我使用StrutsTestCase。再次感谢大家!