Jasper Integer Difference between Developer & Client

Is there a known problem in servoy 5 when developing jasper reports and passing integer fields to the report?

When i do this in developer and have the parameter set to java.lang.Integer in my jasper report, i get an error, saying there is a mismatch and i should have a java.lang.Long field in my report.

Chaning this on my local development machine gets rid of the error. But then when i upload the same report and solution to my production server, i get the opposit error when passing the variable across!

I am using a servoy global integer variable, which for some reason Jasper reports sees as a “Long” in the developer client environment, but as an “Integer” in the server environment.

Seems like a pain to test reports in my development environment, unless i hard code the integers for test purposes?

Is this me or have others experienced the same issue and is there a fix?

David

What is the jasper report definition of the parameter’s DEFAULT type?
Is it Long or Integer?
Have you ensured that the report scripting language to use is Java and NOT Groovy?
If it is Java then how do you define the parameter in the Servoy javascript side?

I learnt the groovy/java the hard way a few weeks ago. 3 days of staring at code for one word!!!

It is defined in the global variable definitions in servoy as an integer.

It is defined as an integer in Jasper.

When running from developer it says i should be using a java.lang.Long field, but when i upload to the server and run it, it works fine.

I just find it a bit odd and frustrating that i get two different results from the same code in developer on my deployed solution. It makes testing the reports on my developer machine impossible unless i send a fixed number across only using the global when i upload.

is it my definition in servoy of an integer that is wrong?

David

Maybe a little more information on your os: version & is it 64 bit by chance?
This could account for the difference?
What servoy version?
What java version?

Sample of your code that does the definition

  1. the global definition
  2. how you pass this to the jasper plugin runReport

Have you tried to assign the value of the global into a local var then pass that?

Have you tried to create a new java.lang.Integer and assign the global value to it then passing this java Integer?

Thanks

//var image = new Packages.java.io.ByteArrayInputStream(global$current_organisation£organisation$id.medilogo)
//var image_awt = Packages.javax.imageio.ImageIO.read(image)
var o = new Object();
o.start_date = globals.search_limit_st;
o.end_date = globals.search_limit_stop;
o.organisation = globals.current_organisation
//o.logo=image_awt;
plugins.jasperPluginRMI.jasperReport('practicemanager','med_sales_summary.jasper',null,'view',o);

I am on a mac pro dev machine and x server for my deployed solution. So you might be correct.

Interestingly, as you will see from the comment out code, I had the opposit when it came to sending a graphic to the report. This worked fine in developer and then gave man an error in the report in the deployed solution. I thought i would go back to basics, but that was odd, i defined the parameter as an image in the jasper file and it worked fine from developer!

//get the logo for medical

//var image = new Packages.java.io.ByteArrayInputStream(global$current_organisation£organisation$id.medilogo)
//var image_awt = Packages.javax.imageio.ImageIO.read(image)

var organisation=globals.current_organisation
var o = new Object();
o.start_date = globals.search_limit_st;
o.end_date = globals.search_limit_stop;
o.organisation = organisation;//globals.current_organisation
//o.logo=image_awt;
plugins.jasperPluginRMI.jasperReport('practicemanager','med_sales_summary.jasper',null,'view',o);

}

didnt help the situation. hard coding o.organisation = 4 made it work in developer.

David

David

David,
Since you had success with the “4” hard coded it might be that the “Long” is OS dependent.
Try forcing the parameter to be converted to an Integer like this:

var o = new Object();
o.start_date = new Packages.java.lang.Integer(globals.search_limit_st);
o.end_date = new Packages.java.lang.Integer(globals.search_limit_stop);
o.organisation = new Packages.java.lang.Integer(globals.current_organisation);

If this works then we can work on the image issue.

Hmm,

tried this (the dates dont matter as they work, but nonetheless i converted them.

var o = new Object();
o.start_date = new Packages.java.util.Date(globals.search_limit_st);
o.end_date = new Packages.java.util.Date(globals.search_limit_stop);
o.organisation = new Packages.java.lang.Integer(globals.current_organisation);

plugins.jasperPluginRMI.jasperReport('practicemanager','med_sales_summary.jasper',null,'view',o);

That gives this error
Incompatible java.util.HashMap value assigned to parameter organisation in the report7 dataset.
at /Users/davidpearce/servoy_workspace5/Recover/forms/Reports_Financials.js:51 (med_sales_summary_bydate)

The full jasper code is:

<?xml version="1.0" encoding="UTF-8"?>
<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="report7" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<style name="Title" isDefault="false" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/>
	<style name="SubTitle" isDefault="false" forecolor="#666666" fontName="Arial" fontSize="18"/>
	<style name="Column header" isDefault="false" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
	<style name="Detail" isDefault="false" fontName="Arial" fontSize="12"/>
	<parameter name="start_date" class="java.util.Date"/>
	<parameter name="organisation" class="java.lang.Integer"/>
	<parameter name="end_date" class="java.util.Date"/>
	<parameter name="logo" class="java.awt.Image" isForPrompting="false"/>
	<queryString>
		<![CDATA[SELECT
     salesledger.`id` AS salesledger_id,
     salesledger.`amount_net` AS salesledger_amount_net,
     salesledger.`amount_total` AS salesledger_amount_total,
     salesledger.`date_created` AS salesledger_date_created,
     client.`name_first` AS client_name_first,
     client.`name_last` AS client_name_last,
     client.`name_title` AS client_name_title,
     client.`fk_solicitor` AS client_fk_solicitor,
     providers.`name` AS providers_name
FROM
     `client` client INNER JOIN `salesledger` salesledger ON client.`id` = salesledger.`fk_client`
     INNER JOIN `providers` providers ON client.`fk_solicitor` = providers.`id`
WHERE
     salesledger.`date_created` > $P{start_date}
 AND salesledger.`date_created` < $P{end_date}
 AND salesledger.`type` = 'MSI'
 AND salesledger.fk_organisation= $P{organisation}

ORDER by salesledger.`fk_provider`,salesledger.`date_created`]]>
	</queryString>
	<field name="salesledger_id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="salesledger_amount_net" class="java.lang.Float">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="salesledger_amount_total" class="java.lang.Float">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="salesledger_date_created" class="java.sql.Timestamp">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="client_name_first" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="client_name_last" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="client_name_title" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="client_fk_solicitor" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="providers_name" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<variable name="provider_total" class="java.lang.Float" resetType="Group" resetGroup="providers_name" calculation="Sum">
		<variableExpression><![CDATA[$F{salesledger_amount_net}]]></variableExpression>
		<initialValueExpression><![CDATA[]]></initialValueExpression>
	</variable>
	<variable name="grand_total" class="java.lang.Float" calculation="Sum">
		<variableExpression><![CDATA[$F{salesledger_amount_net}]]></variableExpression>
	</variable>
	<group name="providers_name">
		<groupExpression><![CDATA[$F{providers_name}]]></groupExpression>
		<groupHeader>
			<band height="40">
				<textField>
					<reportElement style="SubTitle" x="47" y="13" width="506" height="24" forecolor="#006600"/>
					<textElement>
						<font isBold="true"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{providers_name}]]></textFieldExpression>
				</textField>
				<rectangle>
					<reportElement mode="Opaque" x="0" y="13" width="36" height="24" forecolor="#CCCCCC" backcolor="#CCCCCC"/>
				</rectangle>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="26">
				<textField pattern="###0.00">
					<reportElement x="386" y="1" width="167" height="20"/>
					<textElement>
						<font size="14" isBold="true"/>
					</textElement>
					<textFieldExpression class="java.lang.Float"><![CDATA[$V{provider_total}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement x="285" y="1" width="100" height="20"/>
					<textElement textAlignment="Right">
						<font size="14" isBold="true"/>
					</textElement>
					<text><![CDATA[Total £]]></text>
				</staticText>
			</band>
		</groupFooter>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="90" splitType="Stretch">
			<staticText>
				<reportElement style="Title" x="0" y="13" width="263" height="33"/>
				<textElement verticalAlignment="Middle"/>
				<text><![CDATA[Sales Summary]]></text>
			</staticText>
			<staticText>
				<reportElement style="SubTitle" x="67" y="46" width="207" height="22"/>
				<textElement/>
				<text><![CDATA[Medical Sales]]></text>
			</staticText>
			<staticText>
				<reportElement x="263" y="69" width="44" height="20"/>
				<textElement/>
				<text><![CDATA[From:]]></text>
			</staticText>
			<textField pattern="dd/MM/yyyy">
				<reportElement x="297" y="70" width="100" height="20"/>
				<textElement/>
				<textFieldExpression class="java.util.Date"><![CDATA[$P{start_date}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="397" y="68" width="22" height="20"/>
				<textElement/>
				<text><![CDATA[To:]]></text>
			</staticText>
			<textField pattern="dd/MM/yyyy">
				<reportElement x="431" y="68" width="100" height="20"/>
				<textElement/>
				<textFieldExpression class="java.util.Date"><![CDATA[$P{end_date}]]></textFieldExpression>
			</textField>
			<image hAlign="Right">
				<reportElement x="370" y="0" width="183" height="68"/>
				<imageExpression class="java.awt.Image"><![CDATA[$P{logo}]]></imageExpression>
			</image>
		</band>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<pageFooter>
		<band height="26" splitType="Stretch">
			<textField>
				<reportElement style="Column header" x="433" y="0" width="80" height="20"/>
				<textElement textAlignment="Right">
					<font size="10" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
			</textField>
			<textField evaluationTime="Report">
				<reportElement style="Column header" x="513" y="0" width="40" height="20"/>
				<textElement>
					<font size="10" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField pattern="EEEEE dd MMMMM yyyy">
				<reportElement style="Column header" x="0" y="0" width="197" height="20"/>
				<textElement>
					<font size="10" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<lastPageFooter>
		<band height="50">
			<staticText>
				<reportElement x="285" y="18" width="100" height="20"/>
				<textElement textAlignment="Right">
					<font size="14" isBold="true"/>
				</textElement>
				<text><![CDATA[Total £]]></text>
			</staticText>
			<textField pattern="###0.00">
				<reportElement x="386" y="18" width="145" height="20"/>
				<textElement>
					<font size="14" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.Float"><![CDATA[$V{grand_total}]]></textFieldExpression>
			</textField>
		</band>
	</lastPageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>

I loaded your report into iReports 3.7.0 and the organisation is not used anywhere except as an input parameter.
The error that you have may indicate something amiss with the definition of the globals.organisation. Is this defined as an Integer or a Number? Is it a PK?
Try converting the globals.organisation to a string and change the parameter type in the report to a string. Then declare another parameter in the report such as org_id that will be after the organisation parameter. Make the type to be Integer. The default expression of this org_id will be to convert the string to an Integer like this:

new java.lang.Integer($P{organisation})

Perhaps passing the organisation as a string may point out some other issues?

I think that the jasper reports only handles 32 bit values, so check that the value passing for Integer is the same on developer and on the deployed server OS.

Getting a bit above my head,

the parameter is used in the query. It is definitely defined as an integer in servoy, its not a PK its the organisation that my user belongs to when they login to the Saas solution.

Now I am going to tell you something even stranger!.

When i login as another organisation =5 not 4, it works perfectly!!!

When i log back in as =4 i get the error again!

This data is taken from a table, with an integer field storing the number!!! How does anyone explain that then. no other data is sent apart form the dates!!!

Incompatible java.lang.Long value assigned to parameter organisation in the report7 dataset.
at /Users/davidpearce/servoy_workspace5/Recover/forms/Reports_Financials.js:50 (med_sales_summary_bydate)

What I was trying to get you to do was to convert the so-called Integer organisation that is stored in the global (which now you say comes from some other table for which you have not told us the definition of the column) so that when it is stored in the global it is mangled perhaps by some other method running that alters the type of the variable.

Sorry,

The field is a mysql integer field defined as below.

it is defined here:

/**
 * @properties={typeid:35,uuid:"ea0c004c-587f-4a4d-ae97-edfcb4abbbc6",variableType:4}
 */
var current_organisation;

it is populated using the following code on login:

var maxReturnedRows = 1;//useful to limit number of rows
var query = 'select id,fk_organisation,security_edit,fk_user_group,physio_rights from users where username = ? AND password=?';//do not use '.' or special chars in names or aliases if you want to access data by name
var args = new Array();
args[0] = globals.login_username
args[1] = globals.login_password
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, args, maxReturnedRows);


if (dataset.getMaxRowIndex()>0)
{
application.output (dataset.getValue(1, 1))

if (dataset.getValue(1, 4)>0)
var success = databaseManager.addTableFilterParam('practicemanager', null, 'fk_current_user', '=',dataset.getValue(1, 4))
application.output (success)


globals.current_user=dataset.getValue(1, 1);
globals.current_organisation=dataset.getValue(1, 2);

It just seems very odd, or maybe a clue that when a user with organisation 4 logs in the error occurs, but when one with organisation 5 logs in, it doesnt. Maybe the data is simply corrupted for that use or something.
David