This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Why cannot ApplicationContext find an existing file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Why cannot ApplicationContext find an existing file?" Watch "Why cannot ApplicationContext find an existing file?" New topic
Author

Why cannot ApplicationContext find an existing file?

mark baum
Greenhorn

Joined: Aug 21, 2001
Posts: 18
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
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why cannot ApplicationContext find an existing file?
 
Similar Threads
Hibernate with Spring
[beans.xml] cannot be opened because it does not exist
Spring Quartz migration to WAS
Spring 2.5 - Transaction example
Spring with generics