London
London

Reputation: 15274

Instantiate XMLConfiguration from spring

I'm trying to instantiate XMLConfiguration from spring appcontext, my configuration file is in

src/main/resources/

But when I try to pass the constructor args like this :

<constructor-arg type="java.lang.String" value="classpath:/config.xml"/>

or

<constructor-arg type="java.lang.String" value="classpath:config.xml"/>

The spring cannot locate the file :

org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source classpath:/config.xml

But I can see it inside the war, in

\WEB-INF\classes

Can anyone think what I'm doing wrong ?

Upvotes: 0

Views: 1066

Answers (1)

skaffman
skaffman

Reputation: 403441

classpath:/config.xml is Spring-style, and Commons Config doesn't know what that means. You need to pass a path to XMLConfiguration that it knows how to interpret. The javadoc link that you posted suggests that XMLConfiguration requires an actual file path, not a classpath reference.

Upvotes: 2

Related Questions