title: NullPointerException on spring autowiring
body: <p>I wrote a practice problem for Spring autowiring and getting <code>NullPointerException</code>.</p>
  
  <p>here is my code<br>
   <strong>interface: Shape</strong></p>
  
  <pre><code>public interface Shape {
      public void draw();
  }
  </code></pre>
  
  <p><strong>Class : Triangle</strong></p>
  
  <pre><code>    public class Triangle implements Shape{
  
      private Point A;
      private Point B;
      private Point C;
  
      public Point getA() {
          return A;
      }
  
      public void setA(Point a) {
          A = a;
      }
  
      public Point getB() {
          return B;
      }
  
      public void setB(Point b) {
          B = b;
      }
  
      public Point getC() {
          return C;
      }
  
      public void setC(Point c) {
          C = c;
      }
  
      public void draw(){
          System.out.println("PointA("+ A.getX() + "," + A.getY() +")");
          System.out.println("PointB("+ B.getX() + "," + B.getY() +")");
          System.out.println("PointC("+ C.getX() + "," + C.getY() +")");
      }
  }
  </code></pre>
  
  <p><strong>Class : Points</strong></p>
  
  <pre><code>public class Point {
  
      private int x,y;
  
      public int getX() {
          return x;
      }
  
      public void setX(int x) {
          this.x = x;
      }
  
      public int getY() {
          return y;
      }
  
      public void setY(int y) {
          this.y = y;
      }
  
  }
  </code></pre>
  
  <p><strong>Spring XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
      &lt;bean id="triangle" class="org.demo.javabrains.Triangle" autowire="byName"&gt;
      &lt;/bean&gt;
  
      &lt;bean id="A" class="org.demo.javabrains.Point"&gt;
          &lt;property name="x" value="0"/&gt;
          &lt;property name="y" value="0"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="B" class="org.demo.javabrains.Point"&gt;
          &lt;property name="x" value="10"/&gt;
          &lt;property name="y" value="20"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="C" class="org.demo.javabrains.Point"&gt;
          &lt;property name="x" value="30"/&gt;
          &lt;property name="y" value="40"/&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>Main Class</strong></p>
  
  <pre><code>public class DrawingApp {
  
      public static void main(String[] args) {
          ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
          Shape triangle =(Shape) context.getBean("triangle");
          triangle.draw();
  
      }
  
  }
  </code></pre>
  
  <p>I don't know why am I getting NullPointer Exception on this
  when I try to run this code it throws exception </p>
  
  <pre><code>INFO: Loading XML bean definitions from class path resource [spring.xml]
  Exception in thread "main" java.lang.NullPointerException
      at org.demo.javabrains.Triangle.draw(Triangle.java:34)
      at org.demo.javabrains.DrawingApp.main(DrawingApp.java:16)
  </code></pre>
  
  <p>Point A is assigned with value null don't know why</p>