Q:

I am getting null pointer exception while running testng code through XML.But when running code directly its working fine

Code is Grouping in TESTNG
 package testNG_annot;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; 

    public class TestNG_grp1
     {
      @BeforeMethod
      public void CarBM() {
                System.out.println("CarBM");
            }
        ***  // Created group car and Two wheeler//***
            @Test(groups = { "Car" })
            public void Sedan1() {
                System.out.println("Test1-Verna");
            }

            @Test(groups = { "Car" })
            public void Sedan2() {
                System.out.println("Test2-BMW");
            }

            @Test(groups = { "TwoWheeler" })
            public void Scooter1() {
                System.out.println("Test3-ScootyPep");
            }

            @Test(groups = { "TwoWheeler" })
            public void aScooter2() {
                System.out.println("Test4-TVS");
            }
           }

suite.xml           
  <?xml version="1.0" encoding="UTF-8"?> 
  <suite name="grp11"> 
    <test name="group1"> 
      <gropus> 
        <run> 
          <include name="Car"/> 
        </run> 
      </gropus> 
      <classes> 
        <class name="testNG_annot.TestNG_grp1"/> 
      </classes> 
    </test> 
  </suite>

A:

Your spelling for groups tag is wrong. Change the spelling and run it again. 
<groups>
   <run>
      <include name="Car"/>
   </run>
</groups>

