title: Reading xls file in gwt
body: <p>I am looking to read xls file using the gwt RPC and when I am using the code which excecuted fine in normal file it is unable to load the file and giving me null pointer exception.</p>
  
  <p>Following is the code
  {
  {</p>
  
  <pre><code>import com.arosys.readExcel.ReadXLSX;
  import com.google.gwt.user.server.rpc.RemoteServiceServlet;
  import org.Preview.client.GWTReadXL;
  import java.io.InputStream;
  import com.arosys.customexception.FileNotFoundException;
  import com.arosys.logger.LoggerFactory;
  import java.util.Iterator;
  import org.apache.log4j.Logger;
  import org.apache.poi.xssf.usermodel.XSSFCell;
  import org.apache.poi.xssf.usermodel.XSSFRow;
  import org.apache.poi.xssf.usermodel.XSSFSheet;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  /**
   *
   * @author Amandeep
   */
  public class GWTReadXLImpl extends RemoteServiceServlet implements GWTReadXL
  {
      private String fileName;
      private String[] Header=null;
      private String[] RowData=null;
      private int sheetindex;
      private String sheetname;
      private XSSFWorkbook workbook;
      private  XSSFSheet sheet;
      private static Logger logger=null;
  
  
  public void loadXlsxFile() throws Exception
      {
         logger.info("inside loadxlsxfile:::"+fileName);
          InputStream resourceAsStream =ClassLoader.getSystemClassLoader().getSystemResourceAsStream("c:\\test2.xlsx");
          logger.info("resourceAsStream-"+resourceAsStream);
          if(resourceAsStream==null)
             throw new FileNotFoundException("unable to locate give file");
          else
          {
                  try
                  {
                      workbook = new XSSFWorkbook(resourceAsStream);
                      sheet  = workbook.getSheetAt(sheetindex);
                  }
                  catch (Exception ex)
                  {
                     logger.error(ex.getMessage());
                  }
          }
  
      }// end loadxlsxFile
    public String getNumberOfColumns() throws Exception
      {
          int NO_OF_Column=0; XSSFCell cell = null;
          loadXlsxFile();
          Iterator rowIter = sheet.rowIterator();
          XSSFRow firstRow = (XSSFRow) rowIter.next();
          Iterator cellIter = firstRow.cellIterator();
              while(cellIter.hasNext())
              {
                    cell = (XSSFCell) cellIter.next();
                    NO_OF_Column++;
              }
  
          return NO_OF_Column+"";
      }
  
  }
  
  }
  </code></pre>
  
  <p>I am calling it in client program by this code:</p>
  
  <pre><code>        final AsyncCallback&lt;String&gt; callback1 = new AsyncCallback&lt;String&gt;() {
          public void onSuccess(String result) {
              RootPanel.get().add(new Label("In success"));
              if(result==null)
              {
              RootPanel.get().add(new Label("result is null"));
              }
              RootPanel.get().add(new Label("result is"+result));
  
  
          }
             public void onFailure(Throwable caught) {
             RootPanel.get().add(new Label("In Failure"+caught));
             }
          };
          try{
           getService().getNumberOfColumns(callback1);
     }catch(Exception e){}
  </code></pre>
  
  <p>}</p>
  
  <p>Pls tell me how can I resolve this issue as the code runs fine when run through the normal java file.</p>