我使用 Jaspersoft studio 6.3.1 创建了一个包含Web服务数据源的报告。
除非我尝试在eclipse下的Java项目中集成此报告,否则它会生成错误。
实际上我不知道我是否做好了整合。我将jrxml文件复制到我的桌面,然后在按钮单击监听器事件中调用报告:
JasperReport jasperReport = JasperCompileManager.compileReport("C:\\Users\\cpfr\\Desktop\\Blank_A4_7.jrxml");
// Parameters for report : OrientDB test database
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(WebServiceDataAdapterService.URI_KEY, "http://services.groupkt.com/state/search/IND?text=pradesh");
parameters.put(WebServiceDataAdapterService.VERB_KEY, "get");
parameters.put(WebServiceDataAdapterService.LANGUAGE_KEY, LanguageType.JSON);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters); //, mainDataSource);
JasperExportManager.exportReportToPdfFile(jasperPrint, "aaaaaaa.pdf");
但我收到了这个错误:
net.sf.jasperreports.extensions.DefaultExtensionsRegistry loadRegistries
AVERTISSEMENT: Extension resource jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/GoogleAuthenticator.jar!/jasperreports_extension.properties was found to be a duplicate of jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/ElasticSearchConnector.jar!/jasperreports_extension.properties in classloader java.net.URLClassLoader@3fee733d
juin 19, 2017 2:35:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from URL [jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-chart-themes-6.3.1%20(1).jar!/net/sf/jasperreports/chartthemes/spring/beans/chartThemesBeans.xml]
juin 19, 2017 2:35:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from URL [jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-chart-themes-6.3.1%20(1).jar!/net/sf/jasperreports/chartthemes/spring/beans/chartConstantsBean.xml]
juin 19, 2017 2:35:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from URL [jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-chart-themes-6.3.1%20(1).jar!/net/sf/jasperreports/chartthemes/spring/beans/defaultChartPropertiesBean.xml]
juin 19, 2017 2:35:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from URL [jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-chart-themes-6.3.1%20(1).jar!/net/sf/jasperreports/chartthemes/spring/beans/eyeCandySixtiesChartPropertiesBean.xml]
juin 19, 2017 2:35:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from URL [jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-chart-themes-6.3.1%20(1).jar!/net/sf/jasperreports/chartthemes/spring/beans/aegeanChartPropertiesBean.xml]
juin 19, 2017 2:35:40 PM net.sf.jasperreports.extensions.DefaultExtensionsRegistry loadRegistries
AVERTISSEMENT: Extension resource jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-javaflow-6.3.1%20(1).jar!/jasperreports_extension.properties was found to be a duplicate of jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/jasperreports-6.3.1%20(1).jar!/jasperreports_extension.properties in classloader java.net.URLClassLoader@3fee733d
juin 19, 2017 2:35:40 PM net.sf.jasperreports.extensions.DefaultExtensionsRegistry loadRegistries
GRAVE: Error instantiating extensions registry for webserviceDataAdapterService from jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/WebServiceDataAdapter.jar!/jasperreports_extension.properties
net.sf.jasperreports.engine.JRRuntimeException: Class com.jaspersoft.webservice.data.WebServiceDataAdapterServiceExtensionRegistryFactory does not implement/extend net.sf.jasperreports.extensions.ExtensionsRegistryFactory.
at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:58)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java:278)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:255)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:175)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:138)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:268)
at net.sf.jasperreports.engine.util.MessageUtil.getMessageProvider(MessageUtil.java:70)
at net.sf.jasperreports.engine.JRRuntimeException.resolveMessage(JRRuntimeException.java:166)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:146)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:138)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
...
at org.apache.commons.logging.impl.Jdk14Logger.log(Jdk14Logger.java:101)
at org.apache.commons.logging.impl.Jdk14Logger.error(Jdk14Logger.java:149)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:194)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:138)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:268)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.findBundles(ComponentsEnvironment.java:109)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getCachedBundles(ComponentsEnvironment.java:99)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getBundles(ComponentsEnvironment.java:87)
at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:93)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:153)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:108)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1595)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1564)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:263)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:219)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:194)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:288)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575)
...
juin 19, 2017 2:35:40 PM net.sf.jasperreports.extensions.DefaultExtensionsRegistry loadRegistries
GRAVE: Error instantiating extensions registry for queryexecuters.webservice from jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/WebServiceDataAdapter.jar!/jasperreports_extension.properties
net.sf.jasperreports.engine.JRRuntimeException: Class com.jaspersoft.webservice.data.query.WebServiceQueryExecuterExtensionRegistryFactory does not implement/extend net.sf.jasperreports.extensions.ExtensionsRegistryFactory.
at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:58)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java:278)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:255)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:175)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:138)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:268)
at net.sf.jasperreports.engine.util.MessageUtil.getMessageProvider(MessageUtil.java:70)
at net.sf.jasperreports.engine.JRRuntimeException.resolveMessage(JRRuntimeException.java:166)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:146)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:138)
...
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:194)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:138)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:268)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.findBundles(ComponentsEnvironment.java:109)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getCachedBundles(ComponentsEnvironment.java:99)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getBundles(ComponentsEnvironment.java:87)
at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:93)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:153)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:108)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1595)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1564)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:263)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:219)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:194)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:288)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575)
...
juin 19, 2017 2:35:40 PM net.sf.jasperreports.extensions.DefaultExtensionsRegistry loadRegistries
GRAVE: Error instantiating extensions registry for authenticatorgoogleaaa from jar:file:/C:/Jaspersoft/jasperreports-server-cp-6.3.0/apache-tomcat/lib/ElasticSearchConnector.jar!/jasperreports_extension.properties
net.sf.jasperreports.engine.JRRuntimeException: Class com.jaspersoft.jasperreports.data.elasticsearch.ElasticSearchConnectorExtensionRegistryFactory does not implement/extend net.sf.jasperreports.extensions.ExtensionsRegistryFactory.
at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:58)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java:278)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:255)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:175)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:138)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:268)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.findBundles(ComponentsEnvironment.java:109)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getCachedBundles(ComponentsEnvironment.java:99)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getBundles(ComponentsEnvironment.java:87)
at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:93)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:153)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:108)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1595)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1564)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:263)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:219)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:194)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:288)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575)
at com.compart.JasperR.MyUI.lambda$0(MyUI.java:82
...
juin 19, 2017 2:35:40 PM org.apache.commons.digester.Digester endElement
GRAVE: End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:278)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:220)
at org.apache.commons.digester.Rule.end(Rule.java:257)
at org.apache.commons.digester.Digester.endElement(Digester.java:1345)
at net.sf.jasperreports.engine.xml.JRXmlDigester.endElement(JRXmlDigester.java:256)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:857)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
我的 jrxml :
<?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="Blank_A4_7" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8caa250b-0abd-4875-80f2-5cb3830c8129">
<subDataset name="Dataset1" uuid="d768de86-8358-4c77-8997-35879be0e315">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="RemoraWS"/>
<queryString language="WebServiceQuery">
<![CDATA[{
"getparameters" : { },
"fieldsMap" : {
"country" : "country",
"name" : "name",
"abbr" : "abbr",
"area" : "area",
"largest_city" : "largest_city",
"capital" : "capital"
},
"fields" : [ {
"name" : "country",
"expression" : "country"
}, {
"name" : "name",
"expression" : "name"
}, {
"name" : "abbr",
"expression" : "abbr"
}, {
"name" : "area",
"expression" : "area"
}, {
"name" : "largest_city",
"expression" : "largest_city"
}, {
"name" : "capital",
"expression" : "capital"
} ],
"options" : {
"contentType" : "application/json",
"rootPath" : "RestResponse.result",
"baseUrl" : "text=pradesh"
},
"headersMap" : { },
"queryData" : "",
"GETParameters" : { }
}]]>
</queryString>
<field name="country" class="java.lang.String"/>
<field name="name" class="java.lang.String"/>
<field name="abbr" class="java.lang.String"/>
<field name="area" class="java.lang.String"/>
<field name="largest_city" class="java.lang.String"/>
<field name="capital" class="java.lang.String"/>
<group name="country">
<groupExpression><![CDATA[$F{country}]]></groupExpression>
</group>
<group name="name">
<groupExpression><![CDATA[$F{name}]]></groupExpression>
</group>
<group name="abbr">
<groupExpression><![CDATA[$F{abbr}]]></groupExpression>
</group>
<group name="area">
<groupExpression><![CDATA[$F{area}]]></groupExpression>
</group>
<group name="largest_city">
<groupExpression><![CDATA[$F{largest_city}]]></groupExpression>
</group>
<group name="capital">
<groupExpression><![CDATA[$F{capital}]]></groupExpression>
</group>
</subDataset>
<queryString language="WebServiceQuery">
<![CDATA[{
"getparameters" : { },
"fieldsMap" : {
"country" : "country",
"name" : "name",
"abbr" : "abbr",
"area" : "area",
"largest_city" : "largest_city",
"capital" : "capital"
},
"fields" : [ {
"name" : "country",
"expression" : "country"
}, {
"name" : "name",
"expression" : "name"
}, {
"name" : "abbr",
"expression" : "abbr"
}, {
"name" : "area",
"expression" : "area"
}, {
"name" : "largest_city",
"expression" : "largest_city"
}, {
"name" : "capital",
"expression" : "capital"
} ],
"options" : {
"contentType" : "application/json",
"rootPath" : "RestResponse.result",
"baseUrl" : "text=pradesh"
},
"headersMap" : { },
"queryData" : "",
"GETParameters" : { }
}]]>
</queryString>
<field name="country" class="java.lang.String"/>
<field name="name" class="java.lang.String"/>
<field name="abbr" class="java.lang.String"/>
<field name="area" class="java.lang.String"/>
<field name="largest_city" class="java.lang.String"/>
<field name="capital" class="java.lang.String"/>
<group name="country">
<groupExpression><![CDATA[$F{country}]]></groupExpression>
</group>
<group name="name">
<groupExpression><![CDATA[$F{name}]]></groupExpression>
</group>
<group name="abbr">
<groupExpression><![CDATA[$F{abbr}]]></groupExpression>
</group>
<group name="area">
<groupExpression><![CDATA[$F{area}]]></groupExpression>
</group>
<group name="largest_city">
<groupExpression><![CDATA[$F{largest_city}]]></groupExpression>
</group>
<group name="capital">
<groupExpression><![CDATA[$F{capital}]]></groupExpression>
</group>
<columnHeader>
<band height="61" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="95" height="30" uuid="2fff2c2b-9902-4088-8a2d-8e8cac46f17c"/>
<text><![CDATA[country]]></text>
</staticText>
<staticText>
<reportElement x="95" y="0" width="92" height="30" uuid="2680b644-9629-4c0f-8077-e19beb86d06c"/>
<text><![CDATA[name]]></text>
</staticText>
<staticText>
<reportElement x="187" y="0" width="92" height="30" uuid="b05555c6-ade2-4212-946b-79917f6b985b"/>
<text><![CDATA[abbr]]></text>
</staticText>
<staticText>
<reportElement x="279" y="0" width="92" height="30" uuid="5f8626d0-5db7-42a4-b589-e27db699a787"/>
<text><![CDATA[area]]></text>
</staticText>
<staticText>
<reportElement x="371" y="0" width="92" height="30" uuid="9e0f765f-7dfd-43c2-b492-d2a38826dd1c"/>
<text><![CDATA[largest_city]]></text>
</staticText>
<staticText>
<reportElement x="463" y="0" width="92" height="30" uuid="8e8f1f66-d341-4566-9d6b-54b15159326f"/>
<text><![CDATA[capital]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="0" y="89" width="95" height="30" uuid="740dafe4-7bbe-4806-a74d-0b653942b4db"/>
<textFieldExpression><![CDATA[$F{country}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="95" y="89" width="92" height="30" uuid="fc1ef024-3af8-4354-9744-051f4d233216"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="187" y="89" width="92" height="30" uuid="b810854f-6062-475f-858a-41de9f77fc0c"/>
<textFieldExpression><![CDATA[$F{abbr}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="279" y="89" width="92" height="30" uuid="f28459b1-8031-4087-be94-6e0be00b2c78"/>
<textFieldExpression><![CDATA[$F{area}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="371" y="89" width="92" height="30" uuid="e534fc1f-4cdb-43c8-842c-bcc1c354e1d7"/>
<textFieldExpression><![CDATA[$F{largest_city}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="463" y="89" width="92" height="30" uuid="8bda6541-6e18-465d-bb69-f8ecd92be9c0"/>
<textFieldExpression><![CDATA[$F{capital}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>