Incompatible net.sf.jasperreports.engine.JRDefault

Cann some one help me.
I want to create Report without datasourse. Only parameters should be sent to the report.


hier is Report and the exception.

How can i solve it????

<?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="Scannblatt"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="563"
columnSpacing="0"
leftMargin="2"
rightMargin="30"
topMargin="144"
bottomMargin="492"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false"
>
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />

<parameter name="PARAM_1" isForPrompting="false" class="java.lang.String"/>
<parameter name="PARAM_2" isForPrompting="false" class="java.lang.String"/>
<parameter name="PARAM_3" isForPrompting="false" class="java.lang.String"/>
<parameter name="PARAM_4" isForPrompting="false" class="java.lang.String"/>
<parameter name="PARAM_5" isForPrompting="false" class="java.lang.String"/>
<parameter name="PARAM_6" isForPrompting="false" class="java.lang.String"/>


<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="0" isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="0" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="0" isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="206" isSplitAllowed="true" >
<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="68"
y="0"
width="495"
height="24"
key="textField-1"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font fontName="Courier New" pdfFontName="Courier-Bold" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{PARAM_1}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="68"
y="186"
width="495"
height="20"
key="textField-3"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement verticalAlignment="Bottom">
<font fontName="Courier New" pdfFontName="Courier-Bold" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{PARAM_6}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="68"
y="38"
width="495"
height="20"
key="textField-4"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font fontName="Courier New" pdfFontName="Courier-Bold" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{PARAM_2}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="68"
y="77"
width="495"
height="20"
key="textField-5"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font fontName="Courier New" pdfFontName="Courier-Bold" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{PARAM_3}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="68"
y="114"
width="495"
height="20"
key="textField-6"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font fontName="Courier New" pdfFontName="Courier-Bold" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{PARAM_4}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="68"
y="152"
width="495"
height="20"
key="textField-7"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font fontName="Courier New" pdfFontName="Courier-Bold" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{PARAM_5}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="0" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="0" isSplitAllowed="true" >
</band>
</pageFooter>
<summary>
<band height="0" isSplitAllowed="true" >
</band>
</summary>
</jasperReport>





net.sf.jasperreports.engine.JRException: Incompatible net.sf.jasperreports.engine.JRDefaultScriptlet value assigned to parameter REPORT_SCRIPTLET in the Scannblatt dataset.
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameter(JRFillDataset.java:873)
at net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:640)
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:596)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:879)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:708)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:123)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:420)
at de.media.ifa.vw.ProcessReportVWAction.processScanblatt(ProcessReportVWAction.java:65)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)


fashist's picture
Joined: Nov 28 2006 - 12:10am
Last seen: 16 years 10 months ago

15 Answers:

Hi,

What version of JasperReports are you using and on what Web server are you deploying it?

Thank you,
Teodor
teodord's picture
53470
Joined: Jun 30 2006 - 9:00am
Last seen: 11 hours 2 min ago
Hi,

I'm seeing this issue also. I'm using iReport/JasperReports 1.2.8, so not running through a WebApp.

Thank you so much for your help.

Kgentile
kgentile1010's picture
Joined: Oct 13 2006 - 1:04am
Last seen: 16 years 11 months ago
Hi,

I'm seeing this issue also. I'm using iReport/JasperReports 1.2.8, so not running through a WebApp.

Thank you so much for your help.

Kgentile
kgentile1010's picture
Joined: Oct 13 2006 - 1:04am
Last seen: 16 years 11 months ago
I'm also having the same problem.

------------

I can't use a Scriptlet in a subreport


--------------------
The exception I get is:

et.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Incompatible net.sf.jasperreports.engine.JRDefaultScriptlet value assigned to parameter REPORT_SCRIPTLET in the companyDataSheetReport_certifications dataset.
at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:582)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:345)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:311)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:275)

When I specify the scriptlet in a subreport.

Also, I'm already passing $P{REPORT_PARAMETERS_MAP} to the subreport.
mattcvincent's picture
Joined: Dec 5 2006 - 1:40am
Last seen: 16 years 10 months ago
Yea I am getting the same error. It only happens when I export multiple reports. One report is using a scriptlet and the other is not. JRException is
Incompatible net.sf.jasperreports.engine.JRDefaultScriptlet value assigned to parameter REPORT_SCRIPTLET

I have been trying to troubleshoot this for a while with no luck. Any help would be excellent. Im using JR 1.3.0.
zmanning's picture
169
Joined: Dec 15 2006 - 5:49am
Last seen: 16 years 9 months ago
Can you explain again what are you doing? "I export multiple reports" is rather vague. A relevant code fragment would help.

Regards,
Lucian
lucianc's picture
87271
Joined: Jul 17 2006 - 1:10am
Last seen: 11 hours 23 min ago
Had the same error here for reports with subreports that have scriptlets. The subreports' scriptlets fail to initialize. Here is the 'offending' code:

In net.sf.jasperreports.engine.fill.JRFillDataset, force the creation of a new scriptlet for subreports:

Code:
..........<br />
protected void setParameterValues(Map parameterValues) throws JRException <br />
{<br />
..........<br />
<br />
//		scriptlet = (JRAbstractScriptlet) parameterValues.get(JRParameter.REPORT_SCRIPTLET);<br />
//		if (scriptlet == null)<br />
//		{<br />
			scriptlet = createScriptlet();<br />
			parameterValues.put(JRParameter.REPORT_SCRIPTLET, scriptlet);<br />
//		}<br />
		scriptlet.setData(parametersMap, fieldsMap, variablesMap, groups);<br />
<br />
........<br />
}<br />
<br />
</td></tr></tbody></table><br />
<br />
<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre>createScriptlet()</td></tr></tbody></table> was never called for subreports because <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre>scriptlet</td></tr></tbody></table> was initialized to <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre>new JRDefaultScriptlet()</td></tr></tbody></table> (!= null) for the parent report.  <br />
<br />
I am guessing the intention was to force subreports to use the parent report's scriptlet in more recent versions of jasperreports.
GalinaM's picture
263
Joined: Apr 29 2007 - 10:33pm
Last seen: 16 years 5 months ago
Hi,
I get the similar type of compatibility exception but not exactly what ur problem is:
check ur jar file whether it was properly placed in ear file of ur application.make sure ur jasper jar file should not be there any where ,i mean in war or ..but only in ear..
May ur problem be rectified.
i made the same mistake by keeping the jar in both ear and war file later on i rectified the mistake and its working properly now.
svntdeepak's picture
Joined: May 20 2007 - 3:44pm
Last seen: 16 years 4 months ago
I am looking for a workaround for the following problem, while upgrading from 0.6 to 1.3.3. Please help.

I have a report that contains a subreport. The subreport uses a scriptlet, while the main report does not.

In JRFillDataset, in the setParameterValues() method, 'scriptlet' is never 'null' for a subreport (because it is 'new JRDefaultScriptlet()', as created by the call to 'createScriptlet()' when initializing the scriptlet for the main report).

setParameterValues() {
....................
scriptlet = (JRAbstractScriptlet) parameterValues.get(JRParameter.REPORT_SCRIPTLET);
if (scriptlet == null)
{
scriptlet = createScriptlet();
parameterValues.put(JRParameter.REPORT_SCRIPTLET, scriptlet);
}
....................

Therefore, the subreport can never have its own scriptlet. The "Incompatible net.sf.jasperreports.engine.JRDefaultScriptlet value assigned to parameter REPORT_SCRIPTLET" exception is thrown.

Thank you in advance!
GalinaM's picture
263
Joined: Apr 29 2007 - 10:33pm
Last seen: 16 years 5 months ago
I can't follow your argumentation. How does the fact that the scriptlet is never null imply that a subreport cannot have its own scriptlet?

Do you have a simple self-contained sample that illustrates this issue?

Are you by any chance using
Code:
<br />
<parametersMapExpression>$P{REPORT_PARAMETERS_MAP}</parametersMapExpression><br />
</td></tr></tbody></table><br />
for the subreport?<br />
<br />
Regards,<br />
Lucian
lucianc's picture
87271
Joined: Jul 17 2006 - 1:10am
Last seen: 11 hours 23 min ago
I had the similar problem with the incompatible for the scrptlet on subreports.

My solution was not using the same data map. In my first version I was using for the main report and the subreport the same data mapping.
But it seems that jasper is doing a lot of changes there. So simply using a new new data map

Map yourLocalMap = new HashMap();

yourLocalMap .putAll(yourMasterMap);

and adding the map for subreports with:
<paramteresMapExpression>$P{yourLocalMap }</parametersMapExcepression>

(as you can see I'm using a parameter for adding the map)

Btw. I nerver was reading that before but adding subreports into the summary is a good place to concatinate reports into one file.

Hope that is helping, best regards
Markus
markdr's picture
118
Joined: Mar 3 2007 - 12:23am
Last seen: 1 day 8 hours ago
After nearly a day tinkering to try to work around
this bug, I found a way, at least for my reports.

Here's a description of the situation:

ReportA is the main report, it includes ReportB as a
subreport, and also has its own scriptlet.

ReportB uses a data source passed in from ReportA, but
does not need any scriptlet, and does not declare one.

In ReportA's <subreport> tag to include ReportB, I
have some simple markup:

Code:
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression><br />
<subreportParameter name="SUBREPORT_DIR"><br />
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression><br />
</subreportParameter><br />
<dataSourceExpression><![CDATA[$P{REPORT_SCRIPTLET}.getMyOutputDataSource()]]></dataSourceExpression><br />
</td></tr></tbody></table><br />
.. and the getMyDataSource() call in there does work.<br />
That wasn't the problem.<br />
<br />
The problem was that somehow, ReportA is passing in<br />
its own definition of REPORT_SCRIPTLET, which ReportB<br />
did not define at all, and the report engine probably<br />
automatically chooses the wrong type for it.  When<br />
the automatic type and the type from ReportA do not<br />
match up, the exception is thrown.<br />
<br />
To fix this, all I had to do was:<br />
<br />
In ReportB, set the exact same scriptlet settings as<br />
in ReportA.  Then, they both set the same type for<br />
REPORT_SCRIPTLET, and the exception never happens.<br />
<br />
If it is possible to not send ReportB the<br />
REPORT_SCRIPTLET parameter at all, that would be<br />
best, I suppose.  I'm going to see if I can do that.<br />
But, it would sure be nice if I didn't need to spend<br />
time doing all this..<br />
<br />
--<br />
Jason Brittain
jasonb's picture
119
Joined: Feb 6 2007 - 9:55am
Last seen: 16 years 7 months ago
Okay, I found a fix. Wherever you have a <subreport>
element to include a subreport, instead of doing this:

Code:
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression><br />
</td></tr></tbody></table><br />
<br />
.. do this instead:<br />
<br />
<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><parametersMapExpression><![CDATA[new HashMap($P{REPORT_PARAMETERS_MAP})]]></parametersMapExpression><br />
</td></tr></tbody></table><br />
<br />
If I do that, with the subreport's .jrxml file not<br />
using any scriptlet at all, the problem goes away.<br />
No more exception about the REPORT_SCRIPTLET.<br />
<br />
This is mentioned in passing in the docs, but nothing<br />
is said about what might happen if you do not do it,<br />
and no mention about this particular exception.<br />
*sigh*<br />
<br />
--<br />
Jason Brittain
jasonb's picture
119
Joined: Feb 6 2007 - 9:55am
Last seen: 16 years 7 months ago

I solved the problem !!!

 

When you create the prameter in the iReport, make sure that you changing the Parameter class type in the Properties Panel.

 

beherca's picture
29
Joined: Jun 6 2010 - 6:19pm
Last seen: 13 years 3 months ago
应该是参数类型定义和传递的参数不匹配的原因
leiming19877's picture
Joined: Nov 19 2010 - 3:05pm
Last seen: 10 years 8 months ago
Feedback