Jump to content
Changes to the Jaspersoft community edition download ×

Datasourse problem


Recommended Posts

By: Peter Korolev - pet_on

Datasourse problem

2003-09-16 00:45

Hello everyone!

I have trouble with JasperReports and ireportÂ…

I would like to build report with subreport. I receive data from Bean. I want fill my subreport with a custom datasource. So Â… when I read

http://sourceforge.net/forum/forum.php?thread_id=894478&forum_id=217623

I do nextÂ…

I implement parametr in masterReport with class type ru.Mypack.SimpleReportDataSource (this class implements JRDataSource )Â…

I use iReport. When I work with dialog (properties) of subreport element I customize bookmark “Subreport 1”:

“Use datasource expression”

expression - $P{param1}.

In my program I code nextÂ…

Map parameters = new HashMap();

SimpleReportDataSource srds = new SimpleReportDataSource(attrIndicesMap, reportData);

parameters.put("param1", srds);

JasperFillManager.fillReportToFile("MasterReport.jasper", parameters, getConnection());

My xml compile wellÂ… but when I want to fill report (last code string), I take exception:

 

java.io.InvalidClassException: dori.jasper.engine.JasperReport; Local class not compatible: stream classdesc serialVersionUID=406 local class serialVersionUID=302

at java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)

at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)

at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)

at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)

at dori.jasper.engine.util.JRLoader.loadObject(JRLoader.java:120)

at dori.jasper.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:210)

at dori.jasper.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:297)

at dori.jasper.engine.fill.JRFillBand.evaluate(JRFillBand.java:357)

at dori.jasper.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1029)

at dori.jasper.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269)

at dori.jasper.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:160)

at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:457)

at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:373)

at dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:114)

at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:217)

at dori.jasper.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:138)

at dori.jasper.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:106)

at ru.ExampleClass.testReportWithSubreportsOnRetriever(ExampleClass.java:159)

at ru.ExampleClass.main(ExampleClass.java:67)

NESTED BY :

dori.jasper.engine.JRException: Error loading object from file : RefCostsRepReport.jasper

at dori.jasper.engine.util.JRLoader.loadObject(JRLoader.java:126)

at dori.jasper.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:210)

at dori.jasper.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:297)

at dori.jasper.engine.fill.JRFillBand.evaluate(JRFillBand.java:357)

at dori.jasper.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1029)

at dori.jasper.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269)

 

at dori.jasper.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:160)

at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:457)

at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:373)

at dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:114)

at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:217)

at dori.jasper.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:138)

at dori.jasper.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:106)

at ru.ExampleClass.testReportWithSubreportsOnRetriever(ExampleClass.java:159)

at ru.ExampleClass.main(ExampleClass.java:67)

 

Same resalt when I set class Type dori.jasper.engene.JRDataSource...

Here is xml code of my MasterReport:

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="MasterReport"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="515"

columnSpacing="0"

leftMargin="40"

rightMargin="40"

topMargin="50"

bottomMargin="50"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<parameter name="ProductsSubreport" isForPrompting="true" class="dori.jasper.engine.JasperReport"/>

<parameter name="Field" isForPrompting="true" class="java.lang.Object"/>

<parameter name="srds" isForPrompting="true" class="dori.jasper.engine.JRDataSource"/>

<queryString><![CDATA[sELECT City FROM Address GROUP BY City ORDER BY City]]></queryString>

<field name="City" class="java.lang.String"/>

<title>

<band height="50">

<line direction="TopDown">

<reportElement

mode="Opaque"

x="0"

y="0"

width="515"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</line>

<staticText>

<reportElement

mode="Transparent"

x="0"

y="10"

width="515"

height="30"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" lineSpacing="Single">

<font reportFont="Arial_Normal" size="22"/>

</textElement>

<text>Master Report</text>

</staticText>

</band>

</title>

<pageHeader>

<band height="21">

<rectangle>

<reportElement

mode="Opaque"

x="0"

y="5"

width="515"

height="15"

forecolor="#000000"

backcolor="#333333"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="None" fill="Solid" />

</rectangle>

<staticText>

<reportElement

mode="Opaque"

x="0"

y="5"

width="515"

height="15"

forecolor="#FFFFFF"

backcolor="#333333"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font reportFont="Arial_Bold"/>

</textElement>

<text>City List</text>

</staticText>

<line direction="TopDown">

<reportElement

mode="Opaque"

x="0"

y="20"

width="515"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</line>

</band>

</pageHeader>

 

<detail>

<band height="78">

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="5"

y="5"

width="100"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="true"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font reportFont="Arial_Bold"/>

</textElement>

<textFieldExpression class="java.lang.String">$F{City}</textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="110"

y="5"

width="100"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="false"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="true"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font reportFont="Arial_Bold"/>

</textElement>

<text><![CDATA[(continued)]]></text>

</staticText>

<line direction="TopDown">

<reportElement

mode="Opaque"

x="0"

y="20"

width="515"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="true"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</line>

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="4"

y="25"

width="325"

height="20"

forecolor="#000000"

backcolor="#FFCC99"

positionType="FixRelativeToTop"

isPrintRepeatedValues="false"

isRemoveLineWhenBlank="true"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<subreportParameter name="City">

<subreportParameterExpression>$F{City}</subreportParameterExpression>

</subreportParameter>

<connectionExpression>$P{REPORT_CONNECTION}</connectionExpression>

<subreportExpression class="dori.jasper.engine.JasperReport">$P{ProductsSubreport}</subreportExpression>

</subreport>

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="335"

y="25"

width="175"

height="20"

forecolor="#000000"

backcolor="#99CCFF"

positionType="Float"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="true"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<subreportParameter name="City">

<subreportParameterExpression>$F{City}</subreportParameterExpression>

</subreportParameter>

<connectionExpression>$P{REPORT_CONNECTION}</connectionExpression>

<subreportExpression class="java.lang.String"><![CDATA["AddressReport.jasper"]]></subreportExpression>

</subreport>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="360"

y="55"

width="143"

height="14"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$P{Field}</textFieldExpression>

</textField>

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="117"

y="55"

width="161"

height="14"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<dataSourceExpression>$P{srds}</dataSourceExpression>

<subreportExpression class="java.lang.String"><![CDATA["RefCostsRepReport.jasper"]]></subreportExpression>

</subreport>

</band>

</detail>

 

<pageFooter>

<band height="40">

<line direction="TopDown">

<reportElement

mode="Opaque"

x="0"

y="10"

width="515"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</line>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="200"

y="20"

width="80"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Right" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" > <reportElement

mode="Transparent"

x="280"

y="20"

width="75"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>

</textField>

<rectangle>

<reportElement

mode="Opaque"

x="394"

y="30"

width="0"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</rectangle>

</band>

</pageFooter>

 

</jasperReport>

 

 

 

If someone know how to solve my problem please Â….. help

 

Thanks Â…

 

 

 

 

 

By: Gregory A. Swarthout - gswarthout

RE: Datasourse problem

2003-09-16 10:48

I just love answering the same questions weeks after week. This errors stems from using one version of JasperReports to compile your report design and using another to fill that report. You must use the same version!

 

 

 

 

By: Peter Korolev - pet_on

RE: Datasourse problem

2003-09-17 02:59

Thank you very match!

:))

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...