( 0-5 years ) Bsnl, Infosys, Tcs, IBM, HP are Hiring - Apply Here

SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




Spring Framework Dependency Injection

        

Reply
 
LinkBack Thread Tools Display Modes
Old 10-10-07, 04:42 AM   #1 (permalink)
Junior Member
 
Join Date: Oct 2007
Age: 26
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 3 gmahi is on a distinguished road
Spring Framework Dependency Injection

Hallo All,

I am new to Spring. I am working on the Spring Framework Dependency Injection. While running the program I am getting the runtime error. Could any one please help me out. Here are the details.

Address.java

public class Address {

private String streetName="Scharr Str";
private int streetNumber=15;
private int zipCode=70453;
}

BookwormOracle.java:

public class BookwormOracle implements Oracle
{
private Encyclopedia enc;
private Address myaddress;

public void setEncyclopedia(Encyclopedia enc) {
this.enc = enc;
}

public void setAddress(List list)
{
this.address = (Address) list;
}
Address getAddress()
{
return address;
}
public String defineMeaningOfLife() {
return "Encyclopedia's are a waste of money - use the Internet";
}
}

MySpringInjectRef.java

public class MySpringInjectRef
{
public static void main(String[] args)
{
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml"));
InjectRef ref = (InjectRef)factory.getBean("injectRef");
System.out.println(ref.getOracle ().defineMeaningOfLife());

BookwormOracle aRef = (BookwormOracle) factory.getBean("myaddress");
System.out.println(aRef.getAddress());
}
}

beans.xml :







Moehringer LandStr
15
70563











When I try to run this code its giving the following error:

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionSt oreException: Line 12 in XML document from file [C:\Aruna\netbeans\Spring\springdi\samples\MySpring InjectionRef\beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException : The content of element type "property" must match "(description?,(bean|ref|idref|value|null|list|set |map|props)?)".
org.xml.sax.SAXParseException: The content of element type "property" must match "(description?,(bean|ref|idref|value|null|list|set |map|props)?)".
at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.createSAXParseException(ErrorHandlerWrap per.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(ErrorHandlerWrapper.java :131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.handleEndElement(XMLDTDValidator.java:20 17)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.endElement(XMLDTDValidator.java :901)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanEndElement(XMLDocumentFra gmentScannerImpl.java:1772)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDriver.next (XMLDocumentFragmentScannerImpl.java:2923)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl.next(XMLDocumentScannerImpl.java:645)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument (XMLDocumentFragmentScannerImpl.java:508)
at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse (XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:283)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java :222)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:173)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:148)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.(XmlBeanFactory.java :61)
at MySpringInjectRef.main(MySpringInjectRef.java:9)


Where I am exactly wrong. Anyone please help me I am stucked with one and only this.

Thanking you very much,

Best Regards,
Aruna.G

gmahi is offline Offline   Reply With Quote
Reply

Tags
dependency , framework , injection , spring


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free online Education kiran2710 OTHERS 10 03-03-09 11:27 PM
Spring Rolls yathish FOOD / RECIPES 0 25-01-07 01:33 PM
The Java Framework Landscape source JAVA Technologies 0 26-07-06 04:39 PM
Yellow Duck Framework vjsreevs PERL, PYTHON, PHP & MY SQL 1 19-07-06 03:03 PM


All times are GMT +6.5. The time now is 05:59 AM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.2