• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why cannot ApplicationContext find an existing file?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I wrote the following test:



The program could read the file and gave the expected Output:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
default-autowire="byType">

<import resource="databaseContext.xml"/>
<import resource="transactionContext.xml"/>


<bean id="hyperlinkDao" class="org.schubi.du.dao.HybernateHyperLinkDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />

</bean>

</beans>

but then the ClassPathXmlApplicationContext threw the error


org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [src/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [src/applicationContext.xml] cannot be opened because it does not exist

Why's that? What did I do wrong?

Thanks for help

Mark
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ClassPathXmlApplicationContext, as its name says, looks for files in the classpath, so unless your directory (src/applicationContext.xml) is in the classpath, it won't find it.
 
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic