Women in Technology

Hear us Roar



Article:
  What Is Spring, Part 1
Subject:   Problem in Running the code
Date:   2006-07-23 17:18:11
From:   cptanalatriste
Response to: Problem in Running the code

Having the same problem...Help please!!


Carlos Gavidia

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Problem in Running the code
    2009-02-16 23:54:23  arunk3 [View]

    Hi,
    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(
    "H:/Self/Work1/SpringBikeRent/RentABike-context.xml");
    CommandLineView clv = (CommandLineView) ctx.getBean("commandLineView");
    clv.printAllBikes();
    }
    }

    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">
    <beans>
    <bean id="rentaBike" class="com.persistent.brs1.ArrayListRentABike">
    <property name="storeName">
    <value>"Bruce's Bikes"</value>
    </property>
    </bean>
    <bean id="commandLineView" class="com.persistent.brs1.CommandLineView">
    <property name="rentaBike">
    <ref bean="rentaBike" />
    </property>
    </bean>
    </beans>