This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

FileNotFoundException for context file

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to load the context file for a test case, using a absolute path:

private ApplicationContext context;
context = new ClassPathXmlApplicationContext("C:/myfolder/springapp-context.xml");

But it didn't work, got this exception:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [C:/myfolder/springapp-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [C:/myfolder/springapp-context.xml] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [C:/myfolder/springapp-context.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:135)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:307)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
at com.apria.savvion.persistence.service.ApriaCustomInterfaceService.<init>(ApriaCustomInterfaceService.java:76)
at com.apria.savvion.persistence.service.test.ApriaCustomInterfaceServiceTest.setUp(ApriaCustomInterfaceServiceTest.java:18)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Can someone give some input of what I'm doing wrong here? Thanks,
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a full path, use FileSystemXmlApplicationContext instead, because ClassPathXmlApplicationContext will search from your classpath.
 
Sonny hodac
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. i will try and let you know the result.
 
Sonny hodac
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried the FileSystemXmlApplicationContext, still got the same error. Please help:

context = new FileSystemXmlApplicationContext("file:C:/myfolder/spring-context.xml");

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [file:C:/myfolder/spring-context.xml]; nested exception is java.io.FileNotFoundException: C:/myfolder/spring-context.xml (The system cannot find the file specified)
Caused by: java.io.FileNotFoundException: C:/myfolder/spring-context.xml(The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:129)
at java.io.FileInputStream.<init>(FileInputStream.java:89)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:103)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:191)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:103)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:307)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:124)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:68)
at com.apria.savvion.persistence.service.ApriaCustomInterfaceService.<init>(ApriaCustomInterfaceService.java:77)
at com.apria.savvion.persistence.service.test.ApriaCustomInterfaceServiceTest.setUp(ApriaCustomInterfaceServiceTest.java:18)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a file called spring-context.xml in myfolde ? At the DOS prompt, try "DIR C:/myfolder/spring-context.xml".
 
Sonny hodac
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code that load the context:
context = new FileSystemXmlApplicationContext("file:C:\\sbm\\bpm\\Savvion\\BPMStudio\\ApriaSonataDataAdminEJB\\saddAppDev-context.xml");

I do dir at dos prompt for my context file, here the result:
C:\>dir c:\sbm\bpm\Savvion\BPMStudio\ApriaSonataDataAdminEJB\sdaaAppDev-context.
xml
Volume in drive C is CDRIVE
Volume Serial Number is F879-9537

Directory of c:\sbm\bpm\Savvion\BPMStudio\ApriaSonataDataAdminEJB

02/01/2008 11:25 AM 1,929 sdaaAppDev-context.xml
1 File(s) 1,929 bytes
0 Dir(s) 28,175,286,272 bytes free


I ran the Junit test again still got the exception, please help, here the exception:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [file:C:/sbm/bpm/Savvion/BPMStudio/ApriaSonataDataAdminEJB/saddAppDev-context.xml]; nested exception is java.io.FileNotFoundException: C:\sbm\bpm\Savvion\BPMStudio\ApriaSonataDataAdminEJB\saddAppDev-context.xml (The system cannot find the file specified)
Caused by: java.io.FileNotFoundException: C:\sbm\bpm\Savvion\BPMStudio\ApriaSonataDataAdminEJB\saddAppDev-context.xml (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:129)
at java.io.FileInputStream.<init>(FileInputStream.java:89)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:103)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:191)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:103)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:307)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:124)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:68)
at com.apria.savvion.persistence.service.ApriaCustomInterfaceService.<init>(ApriaCustomInterfaceService.java:88)
at com.apria.savvion.persistence.service.test.ApriaCustomInterfaceServiceTest.testSearchQueue(ApriaCustomInterfaceServiceTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, and you don't find anything weird ? Look closely and don't pull your hair out

Your context path : file:C:\\sbm\\bpm\\Savvion\\BPMStudio\\ApriaSonataDataAdminEJB\\saddAppDev-context.xml

The real path : c:\sbm\bpm\Savvion\BPMStudio\ApriaSonataDataAdminEJB\sdaaAppDev-context.xml
 
Sonny hodac
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh...my bad...after watch the same error for a while everything is blurry abit...thanks so much for pointing it out.
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!