首页 > 解决方案 > jasper print not working 错误说 xml 解析错误

问题描述

我在我的项目中使用 japer 3.7.6。Jasper 在我的计算机上本地运行良好。当同一项目托管在 linux 服务器中时,会出现此问题。对于某些报告 jasper 正在工作,但在某些报告中显示以下错误:

在火狐中: 在此处输入图像描述

在 Chrome 中:

在此处输入图像描述

我的碧玉报告代码是这样的:

    <?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="shareDividentReport_np" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <property name="com.jaspersoft.studio.report.description" value=""/>
    <property name="ireport.zoom" value="1.652892561983471"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="address" class="java.lang.String"/>
    <parameter name="institutionName" class="java.lang.String"/>
    <parameter name="scheme" class="java.lang.String"/>
    <parameter name="trxnDate" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="custName" class="java.lang.String">
        <fieldDescription><![CDATA[custName]]></fieldDescription>
    </field>
    <field name="sNo" class="java.lang.Integer"/>
    <field name="address" class="java.lang.String">
        <fieldDescription><![CDATA[address]]></fieldDescription>
    </field>
    <field name="accNo" class="java.lang.String"/>
    <field name="amount" class="java.math.BigDecimal"/>
    <field name="remarks" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="61" splitType="Stretch">
            <textField>
                <reportElement x="337" y="19" width="215" height="20"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font fontName="Arial"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$P{address}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="305" y="-1" width="247" height="20"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font fontName="Arial" isBold="true"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$P{institutionName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="3" y="2" width="142" height="22"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" isBold="true"/>
                </textElement>
                <text><![CDATA[Fund Distribution Report]]></text>
            </staticText>
            <staticText>
                <reportElement x="400" y="41" width="81" height="14"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8" isBold="true"/>
                </textElement>
                <text><![CDATA[Transaction Date :]]></text>
            </staticText>
            <staticText>
                <reportElement x="3" y="41" width="73" height="14"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" size="8" isBold="true"/>
                </textElement>
                <text><![CDATA[Scheme Name :]]></text>
            </staticText>
            <textField>
                <reportElement x="77" y="41" width="124" height="14"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$P{scheme}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="481" y="41" width="70" height="14"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$P{trxnDate}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="17" splitType="Stretch">
            <staticText>
                <reportElement x="3" y="1" width="22" height="14"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <text><![CDATA[#]]></text>
            </staticText>
            <line>
                <reportElement x="1" y="0" width="554" height="1"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="0" y="0" width="1" height="16"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="1" y="16" width="554" height="1"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="25" y="0" width="1" height="16"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="131" y="1" width="1" height="16"/>
            </line>
            <staticText>
                <reportElement x="28" y="1" width="106" height="14"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <text><![CDATA[Name]]></text>
            </staticText>
            <line>
                <reportElement x="201" y="1" width="1" height="16"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement x="204" y="1" width="58" height="14"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <text><![CDATA[Acc No]]></text>
            </staticText>
            <line>
                <reportElement x="261" y="1" width="1" height="16"/>
            </line>
            <line>
                <reportElement x="368" y="1" width="1" height="16"/>
            </line>
            <line>
                <reportElement x="554" y="1" width="1" height="16"/>
            </line>
            <staticText>
                <reportElement x="134" y="1" width="68" height="14"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <text><![CDATA[Address]]></text>
            </staticText>
            <staticText>
                <reportElement x="262" y="0" width="107" height="17">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="1e3ff973-33f4-46e2-8c61-70a570ebcd40"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <text><![CDATA[Amount]]></text>
            </staticText>
            <staticText>
                <reportElement x="370" y="0" width="184" height="17">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="5f9168c6-3ec7-40d1-92ec-fd6608f42808"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <text><![CDATA[Remarks]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="17" splitType="Stretch">
            <line>
                <reportElement x="0" y="-1" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement positionType="Float" x="25" y="0" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="131" y="-1" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="201" y="0" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="261" y="0" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="368" y="0" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="554" y="-1" width="1" height="16" isPrintWhenDetailOverflows="true"/>
            </line>
            <line>
                <reportElement x="0" y="15" width="554" height="1"/>
            </line>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="30" y="-1" width="100" height="16">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="737f7de1-b4b4-49bd-8d44-4fa181039ac1"/>
                </reportElement>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{custName}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="0" y="-1" width="25" height="16">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d6382c06-3ada-460a-9cd4-eb3c7a6404b9"/>
                    <printWhenExpression><![CDATA[$F{sNo}>0]]></printWhenExpression>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.Integer"><![CDATA[$F{sNo}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="135" y="-1" width="66" height="16">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="18069ac2-9301-4317-b20a-447a97937054"/>
                </reportElement>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="202" y="-1" width="56" height="16">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="fb1cc6a9-727b-4827-847a-48952b87e8ba"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{accNo}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
                <reportElement x="262" y="-1" width="101" height="16">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="8a107053-079b-4a12-83ed-5ec9e16a7613"/>
                </reportElement>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{amount}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
                <reportElement x="373" y="-1" width="181" height="16">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="421fa618-29d6-4861-b625-ffa1e0b8d73a"/>
                </reportElement>
                <textElement verticalAlignment="Middle">
                    <font fontName="Arial" size="8"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{remarks}]]></textFieldExpression>
            </textField>
        </band>
    </detail>


</jasperReport>

类似的打印代码是这样的:

JasperPrint jasperPrint;
    try {
        jasperPrint = JasperFillManager.fillReport(reportPath, params,
                new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(lstFundDistReport));

        HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance()
                .getExternalContext().getResponse();
        httpServletResponse.addHeader("Content-disposition", "inline; filename=FundDistReport.pdf");
        ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
        JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
        FacesContext.getCurrentInstance().responseComplete();
        servletOutputStream.close();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

我在我的应用程序中使用相同的代码打印不同的报告。我在本地计算机上重复每个报告都工作正常。但是托管在 Linux 服务器中的相同应用程序给出了这种不寻常的错误。一些报告导出为 pdf,但主要是其他报告出现此问题。

标签: jasper-reports

解决方案


推荐阅读