net.sf.jasperreports.engine.JRException:找不到资源 [英] net.sf.jasperreports.engine.JRException:Resource not found

查看:234
本文介绍了net.sf.jasperreports.engine.JRException:找不到资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 JasperSoft Studio 使用子报表,但我在下面得到了例外。虽然它在那里但找不到子报告文件。

I try to use subreport using JasperSoft Studio but I get the exception below. It cannot find the subreport file although it is there.

net.sf.jasperreports.engine.JRException:Resource not found at: D:\\JASPERREPORTS\\MyReports

以下是主报告的配置

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<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" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0a6d6643-1d79-4e5e-b39d-a773bba37c12">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="kai3_adapter"/>
    <queryString>
        <![CDATA[select * from cm_crew]]>
    </queryString>
    <field name="OID" class="java.math.BigDecimal"/>
    <field name="CREW_OID" class="java.lang.String"/>
    <field name="CONTACT_OID" class="java.math.BigDecimal"/>
    <field name="ACTIVE" class="java.lang.String"/>
    <field name="ONSHIFT" class="java.lang.String"/>
    <field name="SHIFT_ID" class="java.lang.String"/>
    <field name="SHIFT_START" class="java.sql.Timestamp"/>
    <field name="CREW_STATUS" class="java.lang.String"/>
    <group name="CREW_OID">
        <groupExpression><![CDATA[$F{CREW_OID}]]></groupExpression>
    </group>
    <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">
            <staticText>
                <reportElement x="0" y="0" width="141" height="20" uuid="fc7cf2eb-2922-42e3-b446-fa1cba3239d6"/>
                <text><![CDATA[CREW_OID]]></text>
            </staticText>
            <staticText>
                <reportElement x="141" y="0" width="138" height="20" uuid="1fb08aed-592e-437d-9c3c-87e763dc81f8"/>
                <text><![CDATA[ACTIVE]]></text>
            </staticText>
            <staticText>
                <reportElement x="279" y="0" width="138" height="20" uuid="76eaa47f-6f18-4210-a607-a6456b1cc4ed"/>
                <text><![CDATA[ONSHIFT]]></text>
            </staticText>
            <staticText>
                <reportElement x="417" y="0" width="138" height="20" uuid="273fca2c-2b50-4157-ab3b-8545d94855f3"/>
                <text><![CDATA[CREW_STATUS]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="257" splitType="Stretch">
            <textField>
                <reportElement x="0" y="13" width="141" height="20" uuid="ef3acaa1-b11a-4b3d-b90d-7da18fc15dfa"/>
                <textFieldExpression><![CDATA[$F{CREW_OID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="141" y="13" width="138" height="20" uuid="2c29e96a-d712-4aff-9449-46f523ebbad8"/>
                <textFieldExpression><![CDATA[$F{ACTIVE}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="279" y="13" width="81" height="20" uuid="70df46c9-e63a-45a0-8c6e-82e38c260681"/>
                <textFieldExpression><![CDATA[$F{ONSHIFT}]]></textFieldExpression>
            </textField>
            <subreport>
                <reportElement x="380" y="20" width="165" height="170" uuid="3c312fc6-a389-4e46-af09-ddb1bfaa353f"/>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\JASPERREPORTS\\MyReports\\"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>


推荐答案

按照Sharad的回答,如果它仍然没有生成该文件(发生在我身上),你可以试试这个:

Following Sharad's answer, if it still doesn't generate the file (which happened to me), you can try this:

在预览报告之前,你可以先尝试编译它。如果打开jrxml文件(包含子报表的文件),您可能会在编辑器的上方栏中看到一个小图标(带有一些二进制字符串的小文件)。单击此按钮应生成您期望的文件。

Before previewing the report, you can try to compile it first. If you open your jrxml file (the one that includes the subreport), you may notice a little icon (a little file with some binary string) on the upper bar of your editor. Clicking this button should generate the file you're expecting.

我创建了一个新答案,因为我想添加一个显示按钮的图像:

I created a new answer because I wanted to add an image showing the button:

请注意,这也可能有效:使用Project> Clean ...清理包含报告的项目。然后在Project Explorer中右键单击您的项目(通常在左侧),然后单击Build Project。

Notice that this may also work: clean the projects that contain the reports using "Project > Clean...". And then right click your project in the "Project Explorer" (usually on your left), and then click "Build Project".

这篇关于net.sf.jasperreports.engine.JRException:找不到资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆