2012-06-18 5 views
5

existiert:Warum FileSystemXmlApplicationContext FileNotFoundException auf Datei wirft die

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

und es wirft

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

Die Datei vorhanden ist, kann ich

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

und sehen Sie seinen Inhalt. Auch in Windows funktioniert dieser Code - das Problem ist in linus (ich habe ubuntu os)

Kann jemand beraten, was hier falsch ist?

+0

Check this out http://forum.springsource.org/showthread .php? 37155-Path-problem-with-FileSystemXmlApplicationContext – Gamb

Antwort

16

Versuchen Sie, eine FileSystemXmlApplicationContext mit einer URL erstellen, wie:

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

Zur weiteren Erläuterung siehe dazu: http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch05s07.html 5.7.3 FileSystemResource Einsprüche

+0

Danke, das ist genau das. :-) – Julias

+0

Ich habe versucht, das gleiche zu tun, es funktioniert, wenn ich den Code von der IDE ausführen, aber es funktioniert nicht, wenn ich JAR-Datei kompiliere und versuche, es auszuführen, die fileNotFoundException abruft. Irgendeine Idee, was ist schief gelaufen? Danke – Igal

+0

vielleicht deswegen? https://stackoverflow.com/questions/14483160/spring-filesystemxmlapplicationcontext-dont-find-the-bean-configuration-file-an –

Verwandte Themen