Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why FileSystemXmlApplicationContext throws FileNotFoundException on file that exists

Tags:

java

linux

spring

I'm running the following code:

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

and it throws

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

The file exists, I can do

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

and see its content. Also in windows this code is working - the problem is in linus (i have ubuntu os)

Can any one advise what is wrong here?

like image 441
Julias Avatar asked Jun 18 '12 13:06

Julias


1 Answers

Try creating a FileSystemXmlApplicationContext using a Url, like:

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 caveats

like image 162
Istvan Devai Avatar answered Oct 22 '22 19:10

Istvan Devai