Click here to Skip to main content
15,911,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hiii... The above code is for read an Excel file. But dont know why getting an error "

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/poi/xs

sf/usermodel/XSSFWorkbook. I have already attached poi jar files dom4j1.6.1.jar,poi-

scratchpad3.9-20121203.jar,poi-ooxml-schemas-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar,poi-

3.9-20121203.jar,commons-logging-1.1.jar

Java
package com.read;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import java.util.Iterator;
import java.util.ArrayList;
import javax.naming.spi.ObjectFactory;


import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;


import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.*;

@SuppressWarnings("serial")
public class Newjava implements java.io.Serializable{
	
	@SuppressWarnings("deprecation")
	public ObjectFactory createFactory(String file)
	 {
		System.out.println("file - " +file);
		ArrayList<newjava> arr=new ArrayList<newjava>();
		try{
			
			//FileInputStream file1=new FileInputStream("//home//suvi//ATMInformation.xlsx");
			
		
			XSSFWorkbook workbook=new XSSFWorkbook(file);
			
			XSSFSheet sheet=workbook.getSheetAt(0);
			
			Iterator<row> rowIterator=sheet.iterator();
			
			
			while(rowIterator.hasNext())
			{
		    Row row=rowIterator.next();
		    
			Iterator<cell> cellIterator=row.cellIterator();
			
			
			System.out.println("\n Row Number: "+row.getRowNum());
			
			
			while(cellIterator.hasNext())
			{
				Cell cell=cellIterator.next();
			
				switch(cell.getCellType())
				{
				 case Cell.CELL_TYPE_NUMERIC:
					 
					
					 System.out.print(cell.getNumericCellValue() +"\t");
					break;
					
					
				 case Cell.CELL_TYPE_STRING:
					 
					 System.out.print(cell.getStringCellValue() +"\t");break;
					 
				}
			}
			System.out.print(" ");
			}
			
			FileOutputStream out=new FileOutputStream("//home//suvi//ATMInformation.xlsx");
			workbook.write(out);
			out.close();

		}
		catch(FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		return null;
	 }	

	
		/*public static void main(String[] args) {
		// TODO Auto-generated method stub
		Newjava obj=new Newjava();
	}*/

}



please help.
Posted
Updated 12-Nov-13 23:38pm
v3

1 solution

I have simply solve the issue just by adding all the jar files in WEB-INF-->lib folder.


hope this will help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900