ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  What Is Spring, Part 1
Subject:   Problem in Running the code
Date:   2009-02-16 23:54:23
From:   arunk3
Response to: Problem in Running the code

Don know what the exact problem was in the code, maybe coz i am using Spring 2.5.6
Anyways, to make the code runnable,

1) change RentABikeAssembler.java as below
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class RentABikeAssembler {
public static final void main(String[] args) {
FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(
CommandLineView clv = (CommandLineView) ctx.getBean("commandLineView");

Replace the file path to where your RentABike-context.xml is.

2) In ArrayListRentABike.java, provide getters and setters for storeName, as below.
public String getStoreName() {
return storeName;

public void setStoreName(String storeName) {
this.storeName = storeName;

3) if you used packages while creating the classes, then inside RentABike-context.xml, replace the Class names by fully qualified names Ex,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<bean id="rentaBike" class="com.persistent.brs1.ArrayListRentABike">
<property name="storeName">
<value>"Bruce's Bikes"</value>
<bean id="commandLineView" class="com.persistent.brs1.CommandLineView">
<property name="rentaBike">
<ref bean="rentaBike" />