title: java.lang.NoClassDefFoundError: is coming in java servlets
body: <p>Here is my servlet class </p>
  
  <pre><code>package com.zaggle;
  
  import java.io.IOException;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  /**
   * Servlet implementation class FirstServlet
   */
  public class FirstServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
  
  /**
   * @see HttpServlet#HttpServlet()
   */
  public FirstServlet() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
  }
  
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      String[] data;String val=null,name;
      name=request.getParameter("excelsheet");
      System.out.println(name);
          response.setContentType("text/html");
           UploadExcel ex= new UploadExcel();
           data=ex.procedure(name);
       System.out.println(name);
  
      request.setAttribute("val", data);
      System.out.println(val);
  
      String destination="/NewFile1.jsp";
      RequestDispatcher rd=getServletContext().getRequestDispatcher(destination);
      //doGet(request, response);
      rd.forward(request, response);
  
  
  }
  
  }  
  </code></pre>
  
  <p>Here is my normal java class which I am using in servlet class</p>
  
  <pre><code>package com.zaggle;
  
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.Scanner;
  import java.util.Vector;
  import javax.swing.plaf.basic.BasicInternalFrameTitlePane.RestoreAction;
  import org.apache.poi.hssf.record.formula.functions.Goto;
  import org.apache.poi.hssf.usermodel.HSSFCell;
  import org.apache.poi.hssf.usermodel.HSSFRow;
  import org.apache.poi.hssf.usermodel.HSSFSheet;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  
  
  
   public class UploadExcel {
  public String[] procedure(String filename) {
      //  Scanner scanner = new Scanner(System.in);
        //System.out.println("Please enter a filename with extention to upload");
  
      String fileName = "C:\\"+filename;//+scanner.nextLine();
      String[] dataHolder = ReadCSV(fileName);
     // printCellDataToConsole(dataHolder);
      return dataHolder;
  }
  
  public static void printCellDataToConsole(Vector dataHolder) {
      // TODO Auto-generated method stub
      for(int i=0;i&lt;dataHolder.size();i++)
      {
          Vector column=(Vector)dataHolder.elementAt(i);
          for (int j = 0; j &lt; column.size(); j++) {
              HSSFCell myCell = (HSSFCell) column.elementAt(j);
              String stringCellValue = myCell.toString();
  
              System.out.print(stringCellValue + "\t");
      }
      System.out.println();
  
      }
  }
  
  public static String[] ReadCSV(String fileName) {
      // TODO Auto-generated method stub
       Vector cellVectorHolder = new Vector();
       String[] col = null;
       try {
           FileInputStream myInput = new FileInputStream(fileName);
  
           POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
  
           HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
  
           HSSFSheet mySheet = myWorkBook.getSheetAt(0);
  
           Iterator rowIter = mySheet.rowIterator();
  
           while (rowIter.hasNext()) {
                   HSSFRow myRow = (HSSFRow) rowIter.next();
                   Iterator cellIter = myRow.cellIterator();
                   Vector column = new Vector();
                   while (cellIter.hasNext()) {
                           HSSFCell myCell = (HSSFCell) cellIter.next();
                           column.addElement(myCell);
  
                   }
                    col=column.toString().split(" ");
                   cellVectorHolder.addElement(column);
           }
   } catch(IOException ie)
   {
       System.err.println("Please enter a valid input");
  
   }
       catch (Exception e) {
           e.printStackTrace();
   }
   //return cellVectorHolder;
       return col;
  }
  
  }
  </code></pre>
  
  <p>When i run I am getting the error like this</p>
  
  <p>type Exception report</p>
  
  <p>message </p>
  
  <p>description The server encountered an internal error () that prevented it from fulfilling this request.</p>
  
  <p>exception </p>
  
  <p>javax.servlet.ServletException: Servlet execution threw an exception</p>
  
  <p>root cause </p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem
  com.zaggle.UploadExcel.ReadCSV(UploadExcel.java:52)
  com.zaggle.UploadExcel.procedure(UploadExcel.java:24)
  com.zaggle.FirstServlet.doPost(FirstServlet.java:42)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p>Why am I getting this error. Can anyone help me?</p>