我在编译我的jasper报告时得到了这个异常,例外是:
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
这是我的XML文件:
<?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>
以下是我在pom.xml中与Jasper相关的依赖项:
<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>
这是我的java代码:
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);
}
我努力解决这个问题,但我找不到合适的支持,如果您对此有任何疑问,请帮助我。感谢。
答案 0 :(得分:0)
我尝试了几天后才发现问题。
最初的问题是我已经将jasperreports依赖的依赖项逐个添加到我的pom中,我不需要这样做。然后出现了冲突。只有jasperreports和groovy依赖就足够了。如果你不使用groovy,你也不必添加它。
但后来jasperreport说,即使我通过参数传递数据,'文档也没有页面'。那是因为我没有用过
JasperPrint jp = JasperFillManager.fillReport(jr, param, new JREmptyDataSource());
而不是
JasperPrint jp = JasperFillManager.fillReport(jr, param);
JasperReports没有足够的社区支持我不得不自己解决这个问题。无论如何,我建议改进JasperReports库。