I am using Jasper Studio 6.6.0 and Jasper server 7.1.
I have created a simple report with an image from a specified URL.
It generates correctly in Jasper Studio, but in the server it shows empty.
Please refer images attached:
Server Screenshot
Jasper ScreenshotIf you want to show something in the JasperReport without data source or with empty data source then you have two options:
1) Set the When No Data Type property on All Section No Detail option in the Jasper Studio:
In JRXML it can be done by setting whenNoDataType="AllSectionsNoDetail"
attribute on the root <jasperReport>
element.
2) Or you can move content you want to show when there is no data into No Data band of the report:
In JRXML it it can be done by adding of this:
<noData>
<band height="110">
<image>
<reportElement x="0" y="0" width="240" height="110" uuid="d4b9e59b-896e-4881-92a2-c6707c975312"/>
<imageExpression><![CDATA["https://my.image.url/getImage?name=penguin"]]></imageExpression>
</image>
</band>
</noData>
JasperReport renders blank page when there are no data as a default and JasperServer shows The report is empty, so select from above options one you prefer to be able to show the image you want.
The best way to do not have the empty page when no data source is provided, is to trick jasper to think there is a data source:
1) Define an Data Adapter (a simple .xml file) and put it in reports folder:
<?xml version="1.0" encoding="UTF-8" ?><emptyDataAdapter class="net.sf.jasperreports.data.empty.EmptyDataAdapterImpl"><name>Data Adapter fake</name><recordCount>1</recordCount></emptyDataAdapter>
2) Link it into the main report:
<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="repor" language="javascript" pageWidth="612" pageHeight="792" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="c0eee90e-1b1a-4f34-ad99-1112847752de">
<property name="net.sf.jasperreports.data.adapter" value="EmptyDataAdapter.xml"/>
prefix "repo:" to the value of the property for the data adapter, if the xml is deployed on jasper server.
The attribute "whenNoDataType" will be ignored.
Other details here.
来源:https://stackoverflow.com/questions/52849782/why-jasper-reports-shows-empty-report-in-server-but-generates-correctly-in-jasp