Why FileSystemXmlApplicationContext throws FileNotFoundException to a file that exists

I run the following code:

new FileSystemXmlApplicationContext("/data/farm/Server/confData/1000004/contex.xml")

and he throws

java.io.FileNotFoundException: class path resource [data/farm/Server/confData/1000004/contex.xml] cannot be opened because it does not exist

File exists i can do

cat /data/farm/Server/confData/1000004/contex.xml

and see its contents. Also in windows this code works - problem in linus (I have ubuntu os)

Can anyone tell me what's wrong here?

+5
source share
1 answer

Try creating the FileSystemXmlApplicationContext file using Url, for example:

new FileSystemXmlApplicationContext("file:/data/farm/Server/confData/1000004/contex.xml");

For further explanation see this: http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch05s07.html 5.7.3 FileSystemResource Cautions

+16
source

All Articles