首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

linxu上报JasperRunManager cannot be resolved异常

2012-12-23 
linxu下报JasperRunManager cannot be resolved错误最近在学jasperreport,运行了一个例子,在Windows下能跑

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类?求大神指点迷津,谢谢linxu上报JasperRunManager cannot be resolved异常
[解决办法]
"/test.jasper"换成 "\test.jasper",是不是因为windows和Linux下的路径差异导致的,或者是目录结构

热点排行