Two Laptop Bag
The moose likes Spring and the fly likes Configuration Issues with Spring Framework on eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Configuration Issues with Spring Framework on eclipse" Watch "Configuration Issues with Spring Framework on eclipse" New topic

Configuration Issues with Spring Framework on eclipse

Ak Rahul

Joined: Jul 08, 2009
Posts: 21
Hi everyone,
I am new to Spring Frameworks and am using eclipse IDE to run it. I tried a simple program....which seems to be giving some runtime exceptions when I run it. I shall be really grateful if someone can help me with this.

The config.xml is as follows
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<bean id = "firstbean"
class = "InjectionBean"
p:name = "andy"
p:roll = "2121"
p:dept = "Engg"
p:college = "BU"/>


My is as follows:
public class InjectionBean {
private String name, roll, dept, college;

public String getName() {
return name;

public void setName(String name) { = name;

public String getRoll() {
return roll;

public void setRoll(String roll) {
this.roll = roll;

public String getDept() {
return dept;

public void setDept(String dept) {
this.dept = dept;

public String getCollege() {
return college;

public void setCollege(String college) { = college;

public String toString() {
return "InjectionBean [college=" + college + ", dept=" + dept + ", name="
+ name + ", roll=" + roll + ", toString()=" + super.toString()
+ "]";


And I have a main class( that runs this app.

import org.springframework.beans.factory.xml.XmlBeanFactory;

public class Main {

* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
XmlBeanFactory beanXml = new XmlBeanFactory(new ClassPathResource("config.xml"));
InjectionBean firstBean = (InjectionBean) beanXml.getBean("firstbean");


When I am running the main a java application...I am getting the following error/exception.

Jul 8, 2009 6:35:47 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [config.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [config.xml]; nested exception is class path resource [config.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(
at Main.main(
Caused by: class path resource [config.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
... 4 more

I have the commons-logging-1.0.1.jar and spring.jar included in my eclipse project. Any response to get rid of this exception shall be highly appreciated.

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

config.xml is not in your classpath. In Eclipse's Run configuration window, go to the Classpath tab, select User entry, and add the folder where config.xml is in.

[My Blog]
All roads lead to JavaRanch
Ak Rahul

Joined: Jul 08, 2009
Posts: 21
Thanks Christophe. It works fine now. I really appreciate your help.
I agree. Here's the link:
subject: Configuration Issues with Spring Framework on eclipse
jQuery in Action, 3rd edition