I'm trying to write a very simple servlet which must extract data from a csv file and display the result, here is the code:
Reader reader = new FileReader(filePath);
CSVReader csvReader = new CSVReader(reader);
String[] data;
PrintWriter out = response.getWriter();
response.setContentType("text/html");
while((data = csvReader.readNext()) != null){
//do something
}
but then I receive this log:
Type Exception Report
Message Servlet execution threw an exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils com.opencsv.CSVParser.(CSVParser.java:209) com.opencsv.CSVReader.(CSVReader.java:196) com.opencsv.CSVReader.(CSVReader.java:178) com.opencsv.CSVReader.(CSVReader.java:130) com.opencsv.CSVReader.(CSVReader.java:70) TheClass.doGet(TheClass.java:19) javax.servlet.http.HttpServlet.service(HttpServlet.java:634) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note
The full stack trace of the root cause is available in the server logs.
I'set the tomcat-websocket CLASSPATH and copied the jar file in lib directory in WEB-INF but non of them affected. The problem is raised when we make a CSVReader class. Is there anyone for some helps?