Hello
I have just spent 3 hours to trying to get a unit test to run inside
SpringTool Suite 2.3.2
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"/META-INF/application-context-col-fx-ws-test.xml",
"/META-INF/application-context-col-fx-ws.xml" })
public class ColFxServiceEndpointTest {
/* . . . */
}
The unit test works outside of the IDE on the command line, I can
execute “mvn clean test” and then Maven completes successfully.
However trying to run the same thing in Eclipse, or rather STS,
produces
Ijava.lang.IllegalStateException: Failed to load ApplicationContext
at
org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:
308)
at
org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:
109)
at
org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:
75)
at
org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:
333)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:
220)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:
303)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:
240)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
50)
==/////==
Caused by:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Failed to import bean definitions from URL
location [classpath:META-INF/application-context-col-fx-ws.xml]
Offending resource: class path resource [META-INF/application-context-
col-fx-ws-test.xml]; nested exception is
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Failed to import bean definitions from URL
location [classpath:META-INF/application-context-col-fx-services.xml]
Offending resource: class path resource [META-INF/application-context-
col-fx-ws.xml]; nested exception is
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from class path resource [META-INF/
application-context-col-fx-services.xml]; nested exception is
java.io.FileNotFoundException: class path resource [META-INF/
application-context-col-fx-services.xml] cannot be opened because it
does not exist
WHat on Earth is going on?
At first, I thought was a simple problem like it was M2Eclipse plugin,
check: the plugin is indeed enabled, Maven dependencies are preferred
option. Next, I looked at the POM.xml, check: I see we have JUnit 4.7
listed. I looked at the build class path in Eclipse, check: all JAR
appear to be. Finally, I thought it was the resource path was wrong,
so I tried “classpath:/META-INF/application-context-col-fs-ws.xml”.
And finally, I can the resources are in fact in target\classes\META-
INF and target\test-classes\META-INF respectively.
Anyone know what is going on? I looked at the Spring Forum and this
sodding configuration-error-thing with Spring and Unit Testing seems
to be popular! There are no obvious solution that explain, however,
what is going between Maven and Eclipse worlds.
Is this another example of Spring AOP weirdness?
(Google
--
Peter Pilgrim
--
You received this message because you are subscribed to the Google Groups "JAVAWUG" group.
To post to this group, send email to
jav...@googlegroups.com.
To unsubscribe from this group, send email to
javawug+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/javawug?hl=en.