I'm getting the error" java.lang.IllegalStateExcepton: Failed to load the application context "when I run my unit I'm trying to Testing from inside the eclipse The unit looks very simple in the test: But no matter what I start doing with applicationContext.xml I still get the same error file is within a folder / etc / ws, but even if I put a copy in the same folder, it's still me errors is. I am very new to Java, Spring, Eclipse and Ant, and in fact it is not known why this is going wrong.
package com.mycompany.interactive.cs.isales.ispr.ws.productupgrade; Import org.junit.assert; Import org.junit.Test; Import org.junit.runner.RunWith; Import organization Source: Import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith (SpringJUnit4ClassRunner.class) @ContextConfiguration (locations = { "/ applicationContext.xml"}) public class ProductUpgradeTest {@Test public void getProductUpgrade (throws Exception {//System.out.println (PrintClasspath.getClasspathAsString ())); Assert.assertTrue (true); }}
, @ContextConfiguration
.
Tuesday, 15 February 2011
Spring Web Service Unit Tests: java.lang.IllegalStateExcepton: Failed to load Application Context -
The problem is that you specify your @ContextConfiguration
annotation now That your applicationContext.xml is located in the root folder of your system (where this is probably not, because you say it is on / etc / ws). I see two possible solutions:
- Use
@ContextConfiguration (locations = { "/ etc / ws / applicationContext.xml"})
- move your project (your applicationContext.xml file for example) in your WEB-INF folder and
using @ContextConfiguration (locations = { "classpath: applicationContext.xml"})
If in 2, you will need to make sure that the directory in which you place your application is located in your classpath. This can be configured in your project property in Eclipse.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment