• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

On the quest for learning Spring, but need some help

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ive been following a tutorial on youtube and Im upto the point where we start using autowire.  But the program throws a nullpointerexception and the member variables dont get the proper values.  Im including the code so please let me know whats going on

This is the main program "Drawing.java"


My triangle classs "Triangle.java"


The Point class "Point.java"


and finally the xml file "Spring1.xml"


If I remove the autowire tag and include the property statements, then the application works, but if add in the autowire and delete the property statements, then the application gives a null pointer exception in Triangle class at line 54 (where it is supposed to prints the coordinates of point A" and also in the Drawing class at line 11 where the draw method is called.  Whats going on, why is it not working?
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything looks fine with your code ,can you re-arrange your code like below and give a try

from




to

 
Shashank Gokhale
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to work actually.  The problem was, and I dont know why, that I was naming my points A,B,C,D, and I named them as such in the xml file.  The issue was that Eclipse, when generating the getter and setter methods, especially the setter method was passing in lowercase d even though I had used D when declaring the Point D property.  And because the objects are case sensitive, I was getting the null pointer exception
 
The only thing that kept the leeches off of me was this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic