日期:2014-05-19  浏览次数:20692 次

linxu下报JasperRunManager cannot be resolved错误
最近在学jasperreport,运行了一个例子,在Windows下能跑,但是在Linux下出了问题,不解。jsp文件如下:
<%@ page contentType="text/html;charset=utf-8"%> 
    <%@ page import="net.sf.jasperreports.engine.*"%> 
    <%@ page import="java.util.*"%> 
    <%@ page import="java.io.*" %> 
    <%@ page import="java.sql.*" %>
    <%  
    String ctxpath = request.getContextPath();

//     try{

Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://10.1.16.163:3306/esocc_0702?user=root&password=123");
// }catch(ClassNotFoundException e){
// System.out.println("Sorry,can't find the driver");
// e.printStackTrace();
// }catch(SQLException e1){
// System.out.println("Sorry,i don't know");
// e1.printStackTrace();
// }catch(Exception e2){
// System.out.println("It's wrong");
// }

File reportFile = new File(this.getServletContext().getRealPath("/test.jasper"));
Map para = new HashMap();
try{
JasperRunManager.runReportToHtmlFile(reportFile.getPath(),para,conn);
response.sendRedirect(ctxpath+"/test.html");
}catch(Exception e){
System.out.println(e.getMessage());
}
    %> 


错误提示如下:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 21 in the jsp file: /reportRun.jsp
JasperRunManager cannot be resolved
18:  File reportFile = new File(this.getServletContext().getRealPath("/test.jasper"));
19:  Map para = new HashMap();
20:  try{
21:  JasperRunManager.runReportToHtmlFile(reportFile.getPath(),para,conn);
22:  response.sendRedirect(ctxpath+"/test.html");
23:  }catch(Exception e){
24:  System.out.println(e.getMessage());


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


不知道是什么原因,我的jar包是直接把windows下的包(windows下正常运行)复制到Linux下的,不知道问题在哪,是不是少导入了包?导致不能解析JasperRunManager类?求大神指