Women in Technology

Hear us Roar



Article:
  What Is Spring, Part 1
Subject:   Problem in Running the code
Date:   2005-10-21 07:07:05
From:   JavaFacier
Hi,
I have taken all the required steps like created a development environment similar to Spring sample applications.


I have placed the RentABikeAssembler.java file in the src directory and through ANT build script moved all my bytecodes to the classes directory beneth the WEB-INF dir. But, when I run the assembler i get the following runtime exception:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStore
Exception: IOException parsing XML document from class path resource [RentABikeA
pp-context.xml]; nested exception is java.io.FileNotFoundException: class path r
esource [RentABikeApp-context.xml] cannot be opened because it does not exist
.....



Can anybody help.
Regards,
Anil
SCJP

Full Threads Newest First

Showing messages 1 through 2 of 2.

  • Problem in Running the code
    2006-07-23 17:18:11  cptanalatriste [View]

    Having the same problem...Help please!!

    Carlos Gavidia
    • 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>