Make sure you have the xml file in classpath and use Classpathresource instead of Filesystemresource. I think with FileSystemresource we need to give the fully qualified path for the xml file.
On Sat, Oct 11, 2008 at 8:31 AM, jince varghese <[EMAIL PROTECTED]>wrote: > Hi Everybody, > > I am trying to do a hello program using Spring Framework. I > did import the spring.jar file into the classpath. I am using the JBoss > developer studio. I created a spring project and created 4 files as > follows: > > 1. hello.java > ------------------- > * > > public > * *interface* hello > > { > > *public* String sayhello(String a); > > } > > > > 2.* helloImpl.java* > > *--------------------------* > * > > public > * *class* helloimpl *implements* hello > > { > *private* String greeting; > > *public* helloimpl() > > { > > } > > *public* helloimpl(String a) > > { > > greeting=a; > > } > > *public* String sayhello(String s) > > { > > *return* greeting+s; > > } > > *public* *void* setGreeting(String a) > > { > > greeting=a; > > } > > } > > 3. hello.xml > > ------------------------ > > <? > xml version="1.0" encoding="UTF-8"?> > > <! > DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " > http://www.springframework.org/dtd/spring-beans.dtd"> > > > > </ > beans> > > <beans> > > <bean id="hello" class="helloimpl"> > > <property name="greeting"> > > <value>Good Morning!...</value> > > </property> > > </bean> > > </beans> > > *4. helloclient.java* > > *-----------------------------* > * > > import > * java.io.*; > > * > > import > * org.springframework.beans.factory.*; > > * > > import > * org.springframework.beans.factory.xml.*; > > * > > import > * org.springframework.core.io.*; > > * > > public > * *class* helloclient > > { > > *public* *static* *void* main(String args[]) *throws* Exception > > { > > *try* > > { > > System. > *out*.println("please Wait."); > > //Resource res = new ClassPathResource("hello.xml"); > > > > BeanFactory factory = > *new* XmlBeanFactory(*new* FileSystemResource("hello.xml")); > > hello bean1 = (hello)factory.getBean( > "hello"); > > String s = bean1.sayhello( > "Dennis"); > > System. > *out*.println(s); > > } > > *catch*(Exception e1) > > { System. > *out*.println(""+e1); } > > } > > } > > *I am getting an error:* > > please Wait. > > * > > org.springframework.beans.factory.BeanDefinitionStoreException > *: *IOException* parsing XML document from file > [C:\StrutTest\FirstSpringPrj\hello.xml]; nested exception is * > java.io.FileNotFoundException*: hello.xml (The system cannot find the file > specified) > > > > Oct 10, 2008 11:00:43 PM > org.springframework.beans.factory.xml.XmlBeanDefinitionReader > loadBeanDefinitions > > INFO: Loading XML bean definitions from file > [C:\StrutTest\FirstSpringPrj\hello.xml] > Please help me to solve this problem. Looking forward to hear from you. > > > -- > Thanks > Jince Varghese > > > > -- Thanks, Anil. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en -~----------~----~----~----~------~----~------~--~---