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?
Everything looks fine with your code ,can you re-arrange your code like below and give a try
posted 3 years ago
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
May the force of the Java be in all of us !!!
The only thing that kept the leeches off of me was this tiny ad: