I have a java file containing a function. It uses some external API.(I added the external jar files). Now I have a servlet and in doGet() and want to call the function of the above java class. Do i have to write all the import statements for the API in the servlet?
Cause i get error in the servlet doesnot run.
The error HTTP Status 500 - Servlet execution threw an exception
type Exception report
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: jxl/read/biff/BiffException
hello.hello.doGet(hello.java:77)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
java.lang.ClassNotFoundException: jxl.read.biff.BiffException
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
hello.hello.doGet(hello.java:77)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
I copied the External JAR files inside Tomcat 7.0\\lib and it solved the problem.
Got the idea from http://scn.sap.com/thread/1410297
Well is it the correct solution? That is whenever we have to use External API in servlet we have to Configure Build Path add the JARs and also copy the JARs in tomcat\\lib folder?
just import the class in the servlet which has the method. Paste the stack trace or some code which will be helpful to solve the error.
将jar文件复制到项目的WEBINF / lib文件夹中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.