jeff porter created WW-3869:
-------------------------------
Summary: Spring 3.1.2.RELEASE, causes NoClassDefFoundError:
org/springframework/core/env/EnvironmentCapable
Key: WW-3869
URL: https://issues.apache.org/jira/browse/WW-3869
Project: Struts 2
Issue Type: Bug
Components: Plugin - JUnit, Plugin - Spring
Affects Versions: 2.3.4.1
Environment: Windows.
Java 1.6.
Junit 4.
spring '3.1.2.RELEASE' or '3.1.1.RELEASE' or '3.1.0.RELEASE'
struts2-core 2.3.4.1
Tested with struts2-junit-plugin '2.3.5-SNAPSHOT' and '2.3.4.1'
Reporter: jeff porter
trying to load an Action class for unit testing give the following exception...
java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getMethod0(Class.java:2670)
at java.lang.Class.getMethod0(Class.java:2679)
at java.lang.Class.getMethod(Class.java:1603)
at
org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:20)
at
org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:13)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at
org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at
org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException:
org.springframework.core.env.EnvironmentCapable
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 31 more
Here is the example Java code.
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
import org.apache.struts2.StrutsSpringJUnit4TestCase;
import org.junit.Before;
import org.junit.Test;
import com.opensymphony.xwork2.ActionProxy;
public class ATest extends
StrutsSpringJUnit4TestCase<RepublishTransactionsAction>
{
@Before
public void onSetUp() throws Exception
{
ActionProxy proxy = getActionProxy("repubAction");
assertNotNull(proxy);
}
@Test
public void test() {
assertTrue(true);
}
}
If I change my dependencies from:spring '3.1.2.RELEASE'
to spring '3.0.5.RELEASE' then it works. I'm aware the Maven dependency states
it requires 3.0.5 only.
I've look through JIRA and can't find a task for this, or anyone with the same
problem. I've also checked Stack Overflow.
If this is down to user error on my part, then fine. But I'm sure that
its due to a change on the Spring API side.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira