javax.servlet.ServletException错误... [更新] [英] javax.servlet.ServletException error ... [updated]

查看:146
本文介绍了javax.servlet.ServletException错误... [更新]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hiii ...以上代码用于读取Excel文件。但不知道为什么会收到错误



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



sf / usermodel / XSSFWorkbook。我已经附上了poi jar文件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



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

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.

推荐答案

我只是通过在WEB-INF - > lib文件夹中添加所有jar文件来解决问题。





希望这会有所帮助。
I have simply solve the issue just by adding all the jar files in WEB-INF-->lib folder.


hope this will help.


这篇关于javax.servlet.ServletException错误... [更新]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆