• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

autowiring problem in Spring Framework

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
Here is my class Triangle



and this is my spring.xml



this is my application from where I am calling



and this is point Object class


and I am getting output as


Jul 16, 2014 10:02:10 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@10d13e3e: startup date [Wed Jul 16 22:02:10 IST 2014]; root of context hierarchy
Jul 16, 2014 10:02:10 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring.xml]
Exception in thread "main" java.lang.NullPointerException
at Kishor.BeanFactory.Triangle.draw(Triangle.java:139)
at Kishor.BeanFactory.DrawingApplication.main(DrawingApplication.java:36)



what is the error?

Thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which object is null?
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oK this line


at Kishor.BeanFactory.Triangle.draw(Triangle.java:139)



refers to
System.out.println("Point A=("+getPointA().getX()+","+getPointA().getY()+")");


and this line


at Kishor.BeanFactory.DrawingApplication.main(DrawingApplication.java:36)




refers to
tri1.draw();

in Drawing application class
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never used autowire="byName" property of the bean tag myself, but I am pretty sure that the bean names are case sensitive. Since your property is called pointA, you should call your bean pointA and not PointA.

Try that
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did it by using "byName" and it works fine...


Now its sorted out
reply
    Bookmark Topic Watch Topic
  • New Topic