【问题标题】:Report fails on glassfish玻璃鱼报告失败
【发布时间】:2014-01-30 00:25:32
【问题描述】:

我使用 iReport 5.1.0 制作了一份报告并部署在 Tomcat 服务器上,它运行良好。但是当部署在生产服务器(Glassfish 3.1)中时,报告永远不会出现。 glassfish 日志是空的,所以没有发现错误。

当我在 Eclipse 中运行时(Glassfish 的调试模式),执行似乎跳入了

JasperViewer jasperViewer = new JasperViewer(re, false, null);

行。

此消息旁边是我在 Tomcat 中一直使用和工作的代码。

P.D.请原谅我的英语,我的母语是西班牙语。

代码:

public boolean mostrarReporte(String template, Map parametros) {
        JasperReport report = null;
        JasperPrint re = null;
        Connection conn = conexion();
        boolean success = true;

        try {
            String in = FacesUtils.getExternalContext().getRealPath(
                    "/reportTemplates/" + template);
            report = (JasperReport) JRLoader.loadObject(in);

            re = JasperFillManager.fillReport(report, parametros, conn);
            JasperViewer jasperViewer = new JasperViewer(re, false, null);
            // Mostrar el reporte
            jasperViewer.setVisible(true);
            jasperViewer.setDefaultCloseOperation(0);
            parametros.clear();

        } catch (JRException e) {
            success = false;
            e.printStackTrace();
        } finally {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
        return success;
    }

【问题讨论】:

  • 可能是依赖冲突。检查这个问题:stackoverflow.com/questions/4587328/jasperreports-compilereport
  • @chalo1970 是Java小程序的代码吗?
  • @AlexK,不是它,是 Web 应用程序的代码。
  • @chalo1970 你真的想在 JasperViewer 的帮助下在服务器端显示报告吗?
  • @AlexK 我不明白,JasperViewer 在服务器端显示报告?如果是这样,我该怎么做才能在客户端显示报告?是一个网络应用程序,这就是它应该做的事情。

标签: java eclipse tomcat glassfish jasper-reports


【解决方案1】:

验证您的生产服务器上是否拥有所有 jasper 库:它们应该位于 glassfish/domains/domain1/lib/ext 下。如果罐子不存在(或其中一些——如字体或其他非强制性库),您可能会遇到您所描述的行为。还要确保生产机器上的数据库不为空。如果没有要显示的数据,jasper 会显示一个空白页面。

【讨论】:

  • 数据库不是空的,其实我已经用Glassfish在开发电脑上测试过代码,行为和生产服务器一样。此外,jasperreports 中包含的所有库都在 WEB-INF/lib 文件夹中。有什么想法吗?
猜你喜欢
  • 1970-01-01
  • 2013-01-18
  • 1970-01-01
  • 2010-12-31
  • 1970-01-01
  • 2012-06-21
  • 1970-01-01
  • 2013-03-15
  • 2012-06-15
相关资源
最近更新 更多