Harihara_K
Harihara_K

Reputation: 164

JUnit Error: Failed to load ApplicationContext: Offending resource: class path resource

I have been trying to configure application context in Junit like this:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "../application.xml")
public class TestClass{
.....
}

The error I get when I run the JUnit is:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://java.sun.com/xml/ns/javaee]
Offending resource: class path resource [application.xml]

Any idea what might have wrong?

Upvotes: 0

Views: 1109

Answers (1)

user14168816
user14168816

Reputation:

check your application.xml starts with this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
    
...

</beans>

Upvotes: 1

Related Questions