A XML related exception occurred while compiling t

2019-08-31 13:54发布

I'm getting this exception while compiling my jasper report which the exception is :

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:247)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:230)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:218)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:143)
at com.mhveranga.siripathi.utill.ReportGenerator.generateOrderInvoice(ReportGenerator.java:50)
at com.mhveranga.siripathi.utill.ReportGenerator.main(ReportGenerator.java:79)
Caused by: org.xml.sax.SAXException: http://java.sun.com/xml/jaxp/properties/schemaSource
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1197)
at org.apache.commons.digester.Digester.parse(Digester.java:1647)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243)
... 7 more

Here is my XML file :

<?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="order" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Empty">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="294"/>
    <parameter name="custID" class="java.lang.String"/>
    <parameter name="custContact" class="java.lang.String"/>
    <parameter name="custName" class="java.lang.String"/>
    <parameter name="custAddress" class="java.lang.String"/>
    <parameter name="orderID" class="java.lang.String"/>
    <parameter name="mobileBrand" class="java.lang.String"/>
    <parameter name="mobileModel" class="java.lang.String"/>
    <parameter name="mobileIMEI" class="java.lang.String"/>
    <parameter name="isBattery" class="java.lang.String"/>
    <parameter name="isCharger" class="java.lang.String"/>
    <parameter name="isSIM" class="java.lang.String"/>
    <parameter name="isMemory" class="java.lang.String"/>
    <parameter name="description" class="java.lang.String"/>
    <parameter name="note" class="java.lang.String"/>
    <parameter name="date" class="java.lang.String"/>
    <background>
        <band/>
    </background>
    <title>
        <band height="84">
            <staticText>
                <reportElement x="123" y="21" width="297" height="33"/>
                <textElement>
                    <font size="22" isBold="true"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[SIRIPATHI PHONE CENTER]]></text>
            </staticText>
            <line>
                <reportElement x="63" y="54" width="404" height="1"/>
            </line>
        </band>
    </title>
    <pageHeader>
        <band height="109">
            <staticText>
                <reportElement x="203" y="0" width="144" height="20"/>
                <textElement textAlignment="Center">
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Mahawaththe, Batapola]]></text>
            </staticText>
            <staticText>
                <reportElement x="224" y="20" width="103" height="21"/>
                <textElement>
                    <font size="16" isBold="true"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[077 600 1233]]></text>
            </staticText>
            <staticText>
                <reportElement x="203" y="77" width="157" height="20"/>
                <textElement>
                    <font size="12" isBold="true"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Software/Hardware/Unlock]]></text>
            </staticText>
            <staticText>
                <reportElement x="27" y="47" width="505" height="30"/>
                <textElement textAlignment="Center">
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[We repair all types of mobile phones in Siripathi Phone Center and we will guarantee all our repairs to be free of defects.]]></text>
            </staticText>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="36"/>
    </columnHeader>
    <detail>
        <band height="512">
            <staticText>
                <reportElement x="38" y="50" width="78" height="23"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Customer ID : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="119" width="90" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Customer Name : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="84" width="100" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Customer Contact : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="152" width="100" height="18"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Customer Address : ]]></text>
            </staticText>
            <line>
                <reportElement x="38" y="193" width="465" height="1"/>
            </line>
            <staticText>
                <reportElement x="38" y="213" width="62" height="16"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Order ID : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="244" width="100" height="17"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Mobile Brand : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="276" width="100" height="18"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Mobile Model : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="307" width="78" height="17"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Mobile IMEI : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="340" width="58" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Battery : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="170" y="340" width="56" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Charger : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="297" y="340" width="41" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[SIM : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="410" y="340" width="50" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Memory : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="372" width="78" height="16"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Description : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="38" y="445" width="58" height="16"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Note : ]]></text>
            </staticText>
            <textField>
                <reportElement x="148" y="50" width="355" height="23"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{custID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="84" width="355" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{custContact}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="119" width="355" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{custName}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="152" width="355" height="18"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{custAddress}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="213" width="355" height="16"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{orderID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="244" width="355" height="17"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{mobileBrand}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="276" width="355" height="18"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{mobileModel}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="148" y="307" width="355" height="17"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{mobileIMEI}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="96" y="340" width="48" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{isBattery}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="227" y="340" width="42" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{isCharger}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="338" y="340" width="46" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{isSIM}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="460" y="340" width="52" height="19"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{isMemory}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="144" y="372" width="388" height="54"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{description}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="144" y="445" width="388" height="53"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{note}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="38" y="14" width="78" height="23"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Date :]]></text>
            </staticText>
            <textField>
                <reportElement x="148" y="17" width="355" height="20"/>
                <textElement>
                    <font size="12"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="9"/>
    </columnFooter>
    <pageFooter>
        <band height="9"/>
    </pageFooter>
    <summary>
        <band height="8"/>
    </summary>
</jasperReport>

Here are my dependencies related to Jasper in my pom.xml :

        <dependency>

            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>4.1.2</version>
        </dependency>

        <dependency>

            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils-core</artifactId>
            <version>1.8.3</version>

        </dependency>

        <dependency>

            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>

        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging-api</artifactId>
            <version>1.1</version>
        </dependency>


        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>commons-math</groupId>
            <artifactId>commons-math</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupId>commons-vfs</groupId>
            <artifactId>commons-vfs</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>1.7</version>
        </dependency>

       <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>1.7.5</version>
        </dependency>

        <dependency>
                <groupId>com.lowagie</groupId>
                <artifactId>itext</artifactId>
                <version>2.1.7</version>
        </dependency>


        <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.0.1-FINAL</version>
        </dependency>

        <dependency>

            <groupId>com.google.code.maven-play-plugin.org.apache.commons</groupId>
            <artifactId>commons-javaflow</artifactId>
            <version>1209105</version>

        </dependency>

This is my java code :

try {
            JasperReport jr = JasperCompileManager.compileReport(reportSource);
            JasperPrint jp = JasperFillManager.fillReport(jr, param);
            JasperViewer.viewReport(jp);
        } catch (JRException ex) {
            Logger.getLogger(ReportGenerator.class.getName()).log(Level.SEVERE, null, ex);
        }

I tried a lot to get this issue solved but i couldn't find proper support please help me if you have any idea about this. Thanks.

1条回答
放我归山
2楼-- · 2019-08-31 14:12

I just figured out the issue after trying few days.

Initially the issue was that i have added the dependencies which jasperreports depends on one by one manually into my pom which I don't have to do. Then there have been conflicts. Only jasperreports and groovy dependencies are enough. If you don't use groovy you don't have to add that too.

But then later jasperreport said 'The document has no pages' even when I'm passing data through parameters. That is because i haven't used

JasperPrint jp = JasperFillManager.fillReport(jr, param, new JREmptyDataSource());

instead of

JasperPrint jp = JasperFillManager.fillReport(jr, param);

JasperReports doesn't have enough community support i had to figure this out by my self. Anyway i suggest that JasperReports library should be much improved.

查看更多
登录 后发表回答