为什么JasperReports Server显示空报告?

时间:2016-09-23 05:52:55

标签: jasper-reports jasperserver

我在Jaspersoft Studio中创建了一个示例报告

我创建了服务器连接并发布了创建的报告。但是当我打开服务器并检查发布的相同项目时,它会显示空报告。为什么会这样?

连接到jasper服务器: connection to  jasper server

报告设计: report design

  <?xml version="1.0" encoding="UTF-8"?>
   <!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0  -->
        <!-- 2016-09-23T17:10:52  -->
   <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="myCoffee" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ced95029-b569-4027-895c-af2843a4e088">
      <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="jasperadmin"/>
<property name="ireport.jasperserver.reportUnit" value="/public/Samples/newwww_cofeee"/>
<property name="ireport.jasperserver.report.resource" value="/public/Samples/newwww_cofeee_files/main_jrxml"/>
<style name="Title" fontName="Times New Roman" fontSize="50" isBold="true"/>
<style name="SubTitle" forecolor="#736343" fontName="Arial" fontSize="18"/>
<style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" fontName="Arial" fontSize="12"/>
<style name="Row" mode="Transparent">
    <conditionalStyle>
        <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
        <style backcolor="#E6DAC3"/>
    </conditionalStyle>
</style>
<queryString>
    <![CDATA[select * from "ORDERS"]]>
</queryString>
<field name="ORDERID" class="java.lang.Integer"/>
<field name="SHIPNAME" class="java.lang.String"/>
<field name="SHIPADDRESS" class="java.lang.String"/>
<field name="SHIPCITY" class="java.lang.String"/>
<field name="SHIPREGION" class="java.lang.String"/>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="136" splitType="Stretch">
        <image>
            <reportElement x="0" y="0" width="164" height="126" uuid="ddc15723-2728-421f-b95e-2df9faf64ce1"/>
            <imageExpression><![CDATA["coffee.jpg"]]></imageExpression>
        </image>
        <staticText>
            <reportElement style="Title" x="170" y="0" width="263" height="62" uuid="1a652692-054a-40f3-ade5-68d8da36626d"/>
            <textElement verticalAlignment="Middle"/>
            <text><![CDATA[Coffee Title]]></text>
        </staticText>
        <staticText>
            <reportElement style="SubTitle" x="219" y="62" width="196" height="22" uuid="88d4231e-f014-4b0d-b871-1737ba63a1ae"/>
            <textElement>
                <font fontName="Times New Roman"/>
            </textElement>
            <text><![CDATA[Coffee SubTitle]]></text>
        </staticText>
        <staticText>
            <reportElement x="172" y="94" width="383" height="42" uuid="f0bfb1ea-a85a-47cd-a1a4-43f22b45e80f"/>
            <textElement textAlignment="Right">
                <font size="10"/>
            </textElement>
            <text><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce auctor purus gravida arcu aliquam mattis. Donec et nulla libero, ut varius massa. Nulla sed turpis elit. Etiam aliquet mauris a ligula hendrerit in auctor leo lobortis.]]></text>
        </staticText>
        <image>
            <reportElement x="433" y="-115" width="267" height="209" uuid="5d64e5b3-07bb-48ab-89dc-15c0c46bb19a"/>
            <imageExpression><![CDATA["coffee_stain.png"]]></imageExpression>
        </image>
    </band>
</title>
<pageHeader>
    <band splitType="Stretch"/>
</pageHeader>
<columnHeader>
    <band height="16" splitType="Stretch">
        <line>
            <reportElement positionType="FixRelativeToBottom" x="0" y="15" width="555" height="1" uuid="1a61a836-d137-48b1-ad67-6ff64600bf93"/>
            <graphicElement>
                <pen lineWidth="0.5" lineColor="#999999"/>
            </graphicElement>
        </line>
        <staticText>
            <reportElement style="Column header" x="0" y="0" width="111" height="15" forecolor="#736343" uuid="0ff41838-59fc-47bd-9b48-1bc622576a80"/>
            <text><![CDATA[ORDERID]]></text>
        </staticText>
        <staticText>
            <reportElement style="Column header" x="111" y="0" width="111" height="15" forecolor="#736343" uuid="3c5657fa-038a-4b98-a026-2f6203f5c0be"/>
            <text><![CDATA[SHIPNAME]]></text>
        </staticText>
        <staticText>
            <reportElement style="Column header" x="222" y="0" width="111" height="15" forecolor="#736343" uuid="c9f171bf-1fbb-472d-a5ab-d5bd23340350"/>
            <text><![CDATA[SHIPADDRESS]]></text>
        </staticText>
        <staticText>
            <reportElement style="Column header" x="333" y="0" width="111" height="15" forecolor="#736343" uuid="0907046f-988c-4903-9f92-fcc927eb8a14"/>
            <text><![CDATA[SHIPCITY]]></text>
        </staticText>
        <staticText>
            <reportElement style="Column header" x="444" y="0" width="111" height="15" forecolor="#736343" uuid="d9a1b7ba-d450-4f4c-9956-ba21a8ff4066"/>
            <text><![CDATA[SHIPREGION]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="15" splitType="Stretch">
        <frame>
            <reportElement style="Row" mode="Opaque" x="0" y="0" width="555" height="15" uuid="a98495d8-3c8d-4fa0-81f5-30c3efc2f766"/>
            <textField isStretchWithOverflow="true">
                <reportElement style="Detail" x="0" y="0" width="111" height="15" uuid="004e4afd-035d-42f8-8d5f-f2f847459fb5"/>
                <textFieldExpression><![CDATA[$F{ORDERID}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement style="Detail" x="111" y="0" width="111" height="15" uuid="bf9e44ec-80a7-40fc-afca-60227b369850"/>
                <textFieldExpression><![CDATA[$F{SHIPNAME}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement style="Detail" x="222" y="0" width="111" height="15" uuid="60bc8d8f-c31a-491d-acaa-27c2d00a54f9"/>
                <textFieldExpression><![CDATA[$F{SHIPADDRESS}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement style="Detail" x="333" y="0" width="111" height="15" uuid="8b37170b-04ae-4269-9e01-d5e70e5c0b08"/>
                <textFieldExpression><![CDATA[$F{SHIPCITY}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement style="Detail" x="444" y="0" width="111" height="15" uuid="a0ce4789-f7ab-4eb0-94bf-35152ddbf1b5"/>
                <textFieldExpression><![CDATA[$F{SHIPREGION}]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</detail>
<columnFooter>
    <band height="45" splitType="Stretch">
        <line>
            <reportElement positionType="FixRelativeToBottom" x="0" y="3" width="555" height="1" uuid="fa45a887-615a-4d84-a2d7-8a2219671b3c"/>
            <graphicElement>
                <pen lineWidth="0.5" lineColor="#999999"/>
            </graphicElement>
        </line>
    </band>
</columnFooter>
<pageFooter>
    <band height="25" splitType="Stretch">
        <frame>
            <reportElement mode="Opaque" x="-21" y="1" width="597" height="24" forecolor="#D0B48E" backcolor="#F2EBDF" uuid="183682bc-d976-4756-83e0-6625a3f98ed1"/>
            <textField evaluationTime="Report">
                <reportElement style="Column header" x="533" y="0" width="40" height="20" forecolor="#736343" uuid="0193f9b3-1559-491a-8580-b6988863b6a1"/>
                <textElement verticalAlignment="Middle">
                    <font size="10" isBold="false"/>
                </textElement>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="Column header" x="453" y="0" width="80" height="20" forecolor="#736343" uuid="d00b105e-494b-418b-8ac9-8b1b4824f4f0"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="10" isBold="false"/>
                </textElement>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
            <textField pattern="EEEEE dd MMMMM yyyy">
                <reportElement style="Column header" x="22" y="1" width="197" height="20" forecolor="#736343" uuid="0616f3fe-0354-456f-8911-ec30ec51a5ae"/>
                <textElement verticalAlignment="Middle">
                    <font size="10" isBold="false"/>
                </textElement>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</pageFooter>
<summary>
    <band splitType="Stretch"/>
</summary>

1 个答案:

答案 0 :(得分:2)

JasperReports Server上的报告为空,因为很可能在发布数据源时没有选择数据源。

您已使用Jaspersoft Studio附带的示例数据库创建并测试了报告。服务器也必须可以访问相同的数据,或者在这种情况下具有相同结构的相同数据库表。您在发布报告时指定。

幸运的是,服务器上有一个数据源,它具有与Studio中相似的表结构。您需要做的是在同一位置和Report Publishing Wizard重新发布报告以选择Data Source from Repository,然后输入此路径:

  

/公共/样品/ Data_Sources / ExmapleVDS

(打算输入错误)或通过浏览这些文件夹手动选择它:

  

公开&gt;样品&gt;数据源&gt; ExampleVDS

在输入文本字段旁边的Repository Browser按钮触发的...对话框中。

注意:Studio中的服务器连接是使用jasperadmin用户完成的。