JRXML加载异常

时间:2015-04-18 02:52:16

标签: java jasper-reports

当我尝试加载jrxml文件时,会抛出以下异常;

    net.sf.jasperreports.engine.JRException: org.xml.sax.SAXException:     http://java.sun.com/xml/jaxp/properties/schemaSource
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:300)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:283)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:272)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:246)
    at com.ocs.cwb.view.ControllerCWBHome.generate_report(ControllerCWBHome.java:549)
    at com.ocs.cwb.view.ControllerCWBHome.access$19(ControllerCWBHome.java:529)
    at com.ocs.cwb.view.ControllerCWBHome$3.handle(ControllerCWBHome.java:252)
    at com.ocs.cwb.view.ControllerCWBHome$3.handle(ControllerCWBHome.java:1)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at javafx.scene.Node.fireEvent(Unknown Source)
    at javafx.scene.control.Button.fire(Unknown Source)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at javafx.scene.Scene$MouseHandler.process(Unknown Source)
    at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
    at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$154/20031384.get(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
    at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
    at com.sun.glass.ui.View.notifyMouse(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/3326003.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.xml.sax.SAXException: http://java.sun.com/xml/jaxp/properties/schemaSource
    at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1203)
    at org.apache.commons.digester.Digester.parse(Digester.java:1647)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:296)
    ... 64 more

这是我的示例代码;

try {
        JasperDesign jasperDesign = JRXmlLoader
                .load(new FileInputStream(
                        "I:/Projects/Sample/src/com/sam/cwp/report/sapmle.jrxml"));

        String sqlString = "SELECT*FROM Sample WHERE CNO= '156801'";
        JRDesignQuery designQuery = new JRDesignQuery();
        designQuery.setText(sqlString);
        jasperDesign.setQuery(designQuery);

        JasperReport jasperReport = JasperCompileManager
                .compileReport(jasperDesign);
        JasperPrint jasperPrint = JasperFillManager.fillReport(
                jasperReport, null, conn);

        JasperViewer.viewReport(jasperPrint);

    } catch (JRException e) {
        e.printStackTrace();
        System.out.println(e);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

此外,我使用的是JasperReport 6.0.3最新版本 公地的BeanUtils-1.4.jar 公共沼气池-1.7.jar 共享记录-1.0.3.jar 公地集合-3.2.jar iText的-2.1.7.jar

我无法移动到此行JasperDesign jasperDesign = JRXmlLoader.load(path);

这是我的XML;

    <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.3.final using JasperReports Library version 6.0.3  -->
<!-- 2015-04-18T10:44:56 -->
<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="Sample" pageWidth="720" pageHeight="360" orientation="Landscape" columnWidth="300" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="f4d80783-e43a-4696-8470-2175aa6d0130">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MSSQL"/>
    <queryString>
        <![CDATA[SELECT * FROM sample]]>
    </queryString>
    <field name="ID" class="java.math.BigDecimal"/>
    <field name="OID" class="java.lang.String"/>
    <field name="CNO" class="java.lang.String"/>
    <field name="CUST_NO" class="java.lang.String"/>
    <field name="PAYMENT" class="java.lang.String"/>
    <field name="SHIPPHONENO" class="java.lang.String"/>
    <field name="SHIPCNA" class="java.lang.String"/>
    <field name="SHIPADDR1" class="java.lang.String"/>
    <field name="SHIPADDR2" class="java.lang.String"/>
    <field name="SHIPADDR3" class="java.lang.String"/>
    <field name="SHIPADDR4" class="java.lang.String"/>
    <field name="SHIPCOUNTRYID" class="java.lang.String"/>
    <field name="SHIPPOSTALCODE" class="java.lang.String"/>
    <field name="CONCNA" class="java.lang.String"/>
    <field name="CONPHONENO" class="java.lang.String"/>
    <field name="CONADDR1" class="java.lang.String"/>
    <field name="CONADDR2" class="java.lang.String"/>
    <field name="CONADDR3" class="java.lang.String"/>
    <field name="CONADDR4" class="java.lang.String"/>
    <field name="CONCOUNTRYID" class="java.lang.String"/>
    <field name="CONPOSTALCODE" class="java.lang.String"/>
    <field name="COPIES" class="java.lang.String"/>
    <field name="ATTN" class="java.lang.String"/>
    <field name="CONTENTS" class="java.lang.String"/>
    <field name="BFLYERS" class="java.lang.String"/>
    <field name="SFLYERS" class="java.lang.String"/>
    <field name="RUSER" class="java.lang.String"/>
    <field name="RDATE" class="java.lang.String"/>
    <field name="RTIME" class="java.lang.String"/>
    <field name="REMARKS" class="java.lang.String"/>
    <field name="PSTATUS" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="127" splitType="Stretch">
            <textField>
                <reportElement x="81" y="44" width="79" height="20" uuid="48454381-ce78-46c8-a445-ffe05c226610">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CNO}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="161" y="44" width="79" height="20" uuid="bc98f264-765e-4dd4-b32b-3571eb12e0cb">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CUST_NO}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="240" y="44" width="59" height="20" uuid="f82b9de0-aaed-45aa-bc2a-e3d960f829b4">
                    <property name="local_mesure_unitx" value="pixel"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <text><![CDATA[SIN]]></text>
            </staticText>
            <textField>
                <reportElement x="180" y="87" width="160" height="20" uuid="e09f0461-c93c-4efb-a7a5-e1178b882fe5">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPPHONENO}]]></textFieldExpression>
            </textField>
            <componentElement>
                <reportElement x="580" y="1" width="120" height="88" uuid="8c3a74c7-a14f-494d-92cc-0f4c8064a72e"/>
                <jr:QRCode xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <jr:codeExpression><![CDATA["123456789"]]></jr:codeExpression>
                </jr:QRCode>
            </componentElement>
            <textField>
                <reportElement x="525" y="89" width="79" height="20" uuid="c1f28961-fe50-4c90-a9d7-9475edfa6fe9">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONPHONENO}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="342" y="108" width="262" height="18" uuid="cdb21b18-d208-421e-9841-776825e9b167">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONCNA}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band height="81" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <textField>
                <reportElement x="82" y="-18" width="258" height="18" uuid="0b9f5c28-9144-4e67-a491-a5ac4c1dce57">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPCNA}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="82" y="0" width="258" height="18" uuid="6e1c4175-44fe-44aa-ad1d-9d5301387e1d">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPADDR1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="82" y="16" width="258" height="18" uuid="2165d829-3d8e-46e2-b7e5-315a711da4a2">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPADDR2}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="82" y="32" width="258" height="18" uuid="a473cae7-27cb-406b-a2ac-211534511e52">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement>
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPADDR3}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="341" y="1" width="263" height="18" uuid="8374ca3f-dd60-43fa-9d94-5db5f47c0710">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONADDR1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="341" y="19" width="263" height="18" uuid="c88adb09-5661-4de4-90d0-f4af13b0ecca">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONADDR2}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="341" y="38" width="263" height="18" uuid="a2ff1dc4-0ebd-4cce-9628-593579ad6151"/>
                <box leftPadding="15"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONADDR3}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="281" y="56" width="59" height="20" uuid="2c56986c-d177-4836-8eee-ab4fd1280ea2">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPPOSTALCODE}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="388" y="56" width="107" height="20" uuid="996aca66-df72-4dac-be6e-125941c8fa12">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONCOUNTRYID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="548" y="56" width="57" height="20" uuid="628b380b-5972-41af-8917-8cd8a20e162c"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONPOSTALCODE}]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="151" splitType="Stretch">
            <textField>
                <reportElement x="128" y="-25" width="100" height="20" uuid="bab39829-f073-4973-9d70-9b0afa8c2e14">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPCOUNTRYID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="351" y="110" width="174" height="-5" uuid="165a74a0-c477-4df0-8796-2f35f513eecb">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box leftPadding="10"/>
                <textElement verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{CONADDR3}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
</jasperReport>

1 个答案:

答案 0 :(得分:0)

我希望这是因为jasper源文件中的</jr:QRCode>引起的。我也面临这个问题。每当我尝试将QR码插入报表时,如果Jasper版本低于6.0,则Jasper会抛出SAX异常。即使使用Jasper Studio v 6.0.4,它也会生成空白报告。

我希望这是jasper的一个开放问题,我在Jasper社区找到了它。 http://community.jaspersoft.com/jasperreports-server/issues/4681