Jump to content
Changes to the Jaspersoft community edition download ×

berlin.brown

Members
  • Posts

    11
  • Joined

  • Last visited

berlin.brown's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. I am trying to include an svg image into a jasper report. I thought it would be simple Jasper Report Library Version 6.3 and version 6.11 I wanted to load off the classpath as a strream but getting different errors parameters.put("Image", loadImageAsStream("com/services/reportgencore/api/fincalc/primerica-color-logo.svg")); parameters.put("Image", loadImageAsBatikRenderer("com/services/reportgencore/api/fincalc/primerica-color-logo.svg")); Caused by: java.lang.ClassCastException: net.sf.jasperreports.renderers.BatikRenderer cannot be cast to java.awt.Image at mobileFna_1596548402682_188567.evaluate(mobileFna_1596548402682_188567:348 import net.sf.jasperreports.engine.util.JRLoader;import net.sf.jasperreports.renderers.BatikRenderer; How can I load a SVG in this approach? Also, loading to the correct size with stretching
  2. With this simple configuration, I am passing json data to a table. I see an empty document with this setup. What is mssing. <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 --><!-- 2019-04-12T16:26:16 --><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="NewReportPullTable" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bf9e7542-323d-4fb8-bea6-e92da2349533"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="FincalcLoanAdapter "/> <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <subDataset name="Dataset1" uuid="4bf8f7c6-1f32-423a-a26d-c2fb06f19f9c"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="FincalcLoanAdapter "/> <queryString language="json"> <![CDATA[]]> </queryString> <field name="x" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="x"/> <fieldDescription><![CDATA[x]]></fieldDescription> </field> <field name="y" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="y"/> <fieldDescription><![CDATA[y]]></fieldDescription> </field> </subDataset> <queryString language="json"> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="61" splitType="Stretch"/> </columnHeader> <detail> <band height="266" splitType="Stretch"> <componentElement> <reportElement x="180" y="30" width="328" height="236" uuid="7271b389-e82a-4720-8296-7e8f73422453"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="Dataset1" uuid="be75df4a-ce1e-4fec-8c1e-a98f7e0bcdb3"> <datasetParameter name="JSON_INPUT_STREAM"> <datasetParameterExpression><![CDATA[$P{JSON_INPUT_STREAM}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="net.sf.jasperreports.json.source"> <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.json.source}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="net.sf.jasperreports.json.sources"> <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.json.sources}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="net.sf.jasperreports.json.date.pattern"> <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.json.date.pattern}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="net.sf.jasperreports.json.number.pattern"> <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.json.number.pattern}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="JSON_LOCALE"> <datasetParameterExpression><![CDATA[$P{JSON_LOCALE}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="net.sf.jasperreports.json.locale.code"> <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.json.locale.code}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="JSON_TIME_ZONE"> <datasetParameterExpression><![CDATA[$P{JSON_TIME_ZONE}]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="net.sf.jasperreports.json.timezone.id"> <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.json.timezone.id}]]></datasetParameterExpression> </datasetParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:column width="40" uuid="ef1416e4-790a-4527-9302-72d054fdfb83"> <jr:tableHeader style="Table_TH" height="30"/> <jr:tableFooter style="Table_TH" height="30"/> <jr:columnHeader style="Table_CH" height="30"/> <jr:columnFooter style="Table_CH" height="30"/> <jr:detailCell style="Table_TD" height="30"/> </jr:column> </jr:table> </componentElement> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>[/code] [ { "x" : "D", "y" : "Z" } ]
  3. I am using the "demo" samples from jasper reports. It is clear that the hsqldb is running as standalone server. For example: https://github.com/TIBCOSoftware/jasperreports/blob/master/jasperreports/demo/samples/charts/src/ChartsApp.java https://github.com/TIBCOSoftware/jasperreports/blob/master/jasperreports/src/net/sf/jasperreports/engine/util/AbstractSampleApp.java //Change these settings according to your local configuration String driver = "org.hsqldb.jdbcDriver"; String connectString = "jdbc:hsqldb:hsql://localhost"; String user = "sa"; String password = "";
  4. I am trying to connect to the hsqldb database that is running on localhost. I can connect through the runManager fine, but when I try to connect through a jasper reports adapter and hit "Test" I get an error below. When using the runmanager for hsqldb: HSQL Database Engine Server org.hsqldb.jdbcDriver jdbc:hsqldb:hsql://localhost/ user: sa password: empty But when connecting through the database jdbc connector, this does not work: jdbc:hsqldb:hsql://localhost/ Username:sa Password: empty In the jasper client: net.sf.jasperreports.engine.JRException: java.sql.SQLTransientConnectionException: connection exception: connection failure: java.io.EOFException at net.sf.jasperreports.data.jdbc.JdbcDataAdapterService.contributeParameters(JdbcDataAdapterService.java:130) at net.sf.jasperreports.data.AbstractDataAdapterService.test(AbstractDataAdapterService.java:122) at com.jaspersoft.studio.data.wizard.AbstractDataAdapterWizard$3.runOperations(AbstractDataAdapterWizard.java:162) at com.jaspersoft.studio.utils.jobs.CheckedRunnableWithProgress$1.run(CheckedRunnableWithProgress.java:59) at java.lang.Thread.run(Thread.java:745) Caused by: java.sql.SQLTransientConnectionException: connection exception: connection failure: java.io.EOFException at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source) at net.sf.jasperreports.data.jdbc.JdbcDataAdapterService.getConnection(JdbcDataAdapterService.java:168) at net.sf.jasperreports.data.jdbc.JdbcDataAdapterService.contributeParameters(JdbcDataAdapterService.java:128) ... 4 more Caused by: org.hsqldb.HsqlException: connection exception: connection failure: java.io.EOFException at org.hsqldb.error.Error.error(Unknown Source) at org.hsqldb.error.Error.error(Unknown Source) at org.hsqldb.ClientConnection.execute(Unknown Source) at org.hsqldb.ClientConnection.<init>(Unknown Source) ... 9 more And even on the server side, I see this error on the hsql [java] Exception in thread "HSQLDB Connection @56f3bb82" java.lang.NullPointerException [java] at org.hsqldb.ServerConnection.close(Unknown Source) [java] at org.hsqldb.ServerConnection.run(Unknown Source) [java] at java.lang.Thread.run(Thread.java:748)
  5. I am trying to feed a simple JSON array into the chart types but I am getting an empty document when testing through studio. How can you pass an array to a document? For example: { "Data": [ { "x":1, "y":2 }, { "x":1, "y":3 } ]}[/code]And then I want to pass to this chart and data: <queryString> <![CDATA[Data]]> </queryString> <field name="x" class="java.lang.Double"> <property name="net.sf.jasperreports.json.field.expression" value="x"/> </field> <field name="y" class="java.lang.Double"> <property name="net.sf.jasperreports.json.field.expression" value="y"/> </field><xyAreaChart> <chart evaluationTime="Report"> <reportElement x="40" y="20" width="200" height="200" uuid="952fc1ba-070b-4171-9007-62cfdf705e5c"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <xyDataset> <xySeries> <seriesExpression><![CDATA["SERIES 1"]]></seriesExpression> <xValueExpression><![CDATA[$F{x}]]></xValueExpression> <yValueExpression><![CDATA[$F{y}]]></yValueExpression> </xySeries> </xyDataset>[/code]I get a response of an empty document when I try to render. Also, is it possible to have a field of type array? Here is the full jrxml: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 --><!-- 2019-04-08T16:36:59 --><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="GraphTest" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f981967e-6bf6-47a4-bcca-cd45fc19aab9"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="CsvGraph"/> <queryString> <![CDATA[Data]]> </queryString> <field name="x" class="java.lang.Double"> <property name="net.sf.jasperreports.json.field.expression" value="x"/> </field> <field name="y" class="java.lang.Double"> <property name="net.sf.jasperreports.json.field.expression" value="y"/> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="49" splitType="Stretch"> <staticText> <reportElement x="250" y="19" width="100" height="30" uuid="1bb91627-867b-4045-b582-4ef3ff30a7cc"/> <text><![CDATA[simple Line Area Graph]]></text> </staticText> </band> </pageHeader> <columnHeader> <band height="61" splitType="Stretch"> <staticText> <reportElement x="250" y="19" width="100" height="30" uuid="383dbef6-0ee3-4b53-91f7-64f16f5bc745"/> <text><![CDATA[simple Line Area Graph]]></text> </staticText> </band> </columnHeader> <detail> <band height="398" splitType="Stretch"> <xyAreaChart> <chart evaluationTime="Report"> <reportElement x="40" y="20" width="200" height="200" uuid="952fc1ba-070b-4171-9007-62cfdf705e5c"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <xyDataset> <xySeries> <seriesExpression><![CDATA["SERIES 1"]]></seriesExpression> <xValueExpression><![CDATA[$F{x}]]></xValueExpression> <yValueExpression><![CDATA[$F{y}]]></yValueExpression> </xySeries> </xyDataset> <areaPlot> <plot/> <categoryAxisFormat> <axisFormat/> </categoryAxisFormat> <valueAxisFormat> <axisFormat/> </valueAxisFormat> </areaPlot> </xyAreaChart> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"> <staticText> <reportElement x="250" y="19" width="100" height="30" uuid="cc183642-0d72-4347-bcea-e66f0a6e1a72"/> <text><![CDATA[simple Line Area Graph]]></text> </staticText> </band> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>[/code]
  6. I got it to work, but I had to use this format, The field name had to match the JSON expression. <field name="saving.beginningBalance" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="saving.beginningBalance"/> </field>
  7. I am trying to use a JSON stream. It is kind of strange, some JSON data gets loaded but some doesn't.
  8. That fixed the first problem, thanks. The studio is populating data from the JSON properly. How do I get the Java code to populate. What code do I use, I tried the following, final String jsonAsString = mapper.writeValueAsString(recordJsonObjectAfterDecorate.getDataadapter()); logger.info("Reading JSON data into jasper report library: " + jsonAsString); logger.info("Loading report, "+templateresourcefinder); targetStream = new ByteArrayInputStream(jsonAsString.getBytes()); // Build a JSON Datasource // final JsonDataSource jsonStreamDataSource = new JsonDataSource(targetStream); params.put(JsonQueryExecuterFactory.JSON_DATE_PATTERN, "yyyy-MM-dd"); params.put(JsonQueryExecuterFactory.JSON_NUMBER_PATTERN, "#,##0.##"); params.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.US); params.put(JRParameter.REPORT_LOCALE, Locale.US); params.put(JsonQueryExecuterFactory.JSON_INPUT_STREAM, targetStream);[/code] Do you see an issue with the Java code same tempalte file?
  9. With the Java code below and jasperreports studio, I am trying to pass the JSON to the report but the data is not populating. The static text will appear but not the JSON data. If you see below, I am trying to access isSuccessful but no data is returned. Actually, I can't find a reference to any of the fields using the JSON expression in the xml. And JSON: { "calcData": { "data": { "savingsFrequencyIndicator": 12, "saveEachIndicator": 12, "schedulechart": [ { "month": 1, "savings": 123.00, "balance": 1430.00 }, { "month": 2, "savings": 123.00, "balance": 1560.88 } ] }, "type": "savingsData" }, "isSuccessful": true } iss = new ClassPathResource("/com/ca/services/reportgencore/api/testnorthworks.json").getInputStream(); final StringWriter writer = new StringWriter(); IOUtils.copy(iss, writer, "UTF-8"); final String jsonAsString = writer.toString(); System.out.println("JSON as input >>>: "+jsonAsString); targetStream = new ByteArrayInputStream(jsonAsString.getBytes()); // Build a JSON Datasource // final JsonDataSource jsonStreamDataSource = new JsonDataSource(targetStream); params.put(JsonQueryExecuterFactory.JSON_DATE_PATTERN, "yyyy-MM-dd"); params.put(JsonQueryExecuterFactory.JSON_NUMBER_PATTERN, "#,##0.##"); params.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.US); params.put(JRParameter.REPORT_LOCALE, Locale.US); params.put(JsonQueryExecuterFactory.JSON_INPUT_STREAM, targetStream); // Load the compiled template system and output the PDF document final JasperReport report = TestJasperReportUtil.loadJASPERFile("/com/ca/services/reportgencore/api/SimpleDataJust.jasper"); final JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, jsonStreamDataSource); pdf = JasperExportManager.exportReportToPdf(jasperPrint); <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 --> <!-- 2019-02-12T13:27:48 --> <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="JsonOrdersReport" pageWidth="500" pageHeight="842" columnWidth="500" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="5a62986f-c97c-4e2f-b4ed-d9f38960dab4"> <property name="net.sf.jasperreports.json.source" value="data/example_fincalc_data.json"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="FincalcNewMock"/> <queryString language="json"> <![CDATA[.]]> </queryString> <field name="Id" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="OrderID"/> </field> <field name="isSuccessful" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="isSuccessful"/> </field> <pageHeader> <band height="14"> <frame> <reportElement mode="Opaque" x="0" y="2" width="356" height="10" forecolor="#CCFFFF" backcolor="#CCFFFF" uuid="e9af134f-31eb-48be-bd9b-292188f2554f"/> <staticText> <reportElement mode="Opaque" x="0" y="0" width="48" height="10" backcolor="#CCFFFF" uuid="62e5e770-7b05-4ecd-a254-ab0c7f643a37"/> <textElement textAlignment="Right"/> <text><![CDATA[iD]]></text> </staticText> </frame> </band> </pageHeader> <detail> <band height="14"> <textField> <reportElement x="0" y="2" width="51" height="10" uuid="ec54687d-3c95-4647-9db5-fa71a6e81009"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{Id}]]></textFieldExpression> </textField> </band> </detail> <summary> <band height="77"> <staticText> <reportElement x="20" y="20" width="100" height="30" uuid="15321182-a6c8-494d-ba0f-56e71987d588"/> <text><![CDATA[beginning Balance:]]></text> </staticText> <staticText> <reportElement x="190" y="20" width="100" height="30" uuid="e09a4690-13a6-4c85-915e-4c75a091dfd4"/> <text><![CDATA[simple Data 2]]></text> </staticText> <textField> <reportElement key="" x="130" y="33" width="51" height="10" uuid="b055a4bd-cdd8-4b82-8690-6b21055f5212"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{isSuccessful}]]></textFieldExpression> </textField> </band> </summary> </jasperReport> And JSON input that isn't loading: [/code]
×
×
  • Create New...