Calling Jasper Report in Cold fusion

Calling Jasper Report in Cold fusion

Page 1 of 1

2 Replies - 6011 Views - Last Post: 10 February 2009 - 11:51 PM Rate Topic: -----

#1 rgupta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-February 09

Calling Jasper Report in Cold fusion

Posted 10 February 2009 - 07:19 AM

Hi,

I m newbie in jasper report. I m trying to call jasper report in cold fusion 7.
i have included all the jar files required for jasper report in the cfusionMX7/wwwroot/Web-INF folder. the list of jar files are -
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\bsh-1.3.0;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-beanutils-1.7.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-collections-2.1.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-digester-1.7.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-api-1.0.4.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-1.0.4.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\iReport-utils-2.0.1.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\itext-1.3.1.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jasperreports-2.0.2.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcmdline-1.0.2.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcommon-1.0.0.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\poi-2.5.1-final-20040804.jar;
C:\CFUSIONMX7\wwwroot\WEB-INF\lib\sqljdbc.jar;

I m using the SQL Server 2005. i have using Windows ODBC DSN for connecting to SQL Server 2005 and connection is successful.

Here is the cold fusion code -

<cfscript>
system = CreateObject("java", "java.lang.System");
classpath = system.getProperty("java.class.path");
if (FindNoCase("jasperreportss", classpath) LTE 0)
{
classpath = classpath & ";C:\CFUSIONMX7\wwwroot\WEB-INF\lib\bsh-1.3.0;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-beanutils-1.7.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-collections-2.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-digester-1.7.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-api-1.0.4.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-1.0.4.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\iReport-utils-2.0.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\itext-1.3.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jasperreports-2.0.2.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcmdline-1.0.2.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcommon-1.0.0.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\poi-2.5.1-final-20040804.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\sqljdbc.jar;";
system.setProperty("java.class.path", classpath);
}
clazz = CreateObject("java", "java.lang.Class");
clazz.forName("sun.jdbc.odbc.JdbcOdbcDriver");
driverManager = CreateObject("java", "java.sql.DriverManager");
conurl = "jdbc:odbc:test;user=sa;password="userpassword"";
connection = driverManager.getConnection(conurl);

jasperCompileManager = CreateObject("java", "net.sf.jasperreports.engine.JasperCompileManager");

parameters = CreateObject("java", "java.util.HashMap");
parameters.put("ReportTitle", "Basic JasperReport");

jasFillManager=CreateObject("java","net.sf.jasperreports.engine.JasperFillManager");

jasperPrint = jasFillManager.fillReportToFile(jasReport,parameters, connection);
JasperExportManager=CreateObject("java","net.sf.jasperreports.engine.JasperExportManager");

JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\Inetpub\wwwroot\jasperreports\test.pdf");

connection.close();
</cfscript>

When i run this code i m getting following error in compling the jrxml file -

inconvertible types found : int required: java.lang.Integer value = (java.lang.Integer)(1)


so i used the test.jasper file which is complied by ireport itself using Jasper Studio and changed the following lines in code -

jasperFile="/jasperReport/test.jasper";
jasLoader=CreateObject("java","net.sf.jasperreports.engine.util.JRLoader");
clsLoader = CreateObject("java", "java.lang.ClassLoader");
jasReport = jasLoader.loadObjectFromLocation(jasperFile,clsLoader);

jasFillManager=CreateObject("java","net.sf.jasperreports.engine.JasperFillManager");

parameters = CreateObject("java", "java.util.HashMap");
parameters.put("ReportTitle", "Basic JasperReport");

jasperPrint = jasFillManager.fillReportToFile(jasReport,parameters, connection);


but using this code i get the following error -

The report template C:\Inetpub\wwwroot\jasperReport\test.jasper appears to be malformed or contain errors.

Can anyone help me here where i m wrong. or any one can provide me the code or some links where i can get the solution. i m trying since last 2 days in many sites but still didn't get any solution.

Any help would be appreciated

Thanks
Renuka

This post has been edited by rgupta: 10 February 2009 - 07:47 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Calling Jasper Report in Cold fusion

#2 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: Calling Jasper Report in Cold fusion

Posted 10 February 2009 - 04:33 PM

Can you please post the whole cfscript you have so far inside code tags?
Was This Post Helpful? 0
  • +
  • -

#3 rgupta  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-February 09

Re: Calling Jasper Report in Cold fusion

Posted 10 February 2009 - 11:51 PM

View Postbsaunders, on 10 Feb, 2009 - 03:33 PM, said:

Can you please post the whole cfscript you have so far inside code tags?


here is the full cfscript code

<cfscript>
system = CreateObject("java", "java.lang.System");
classpath = system.getProperty("java.class.path");
if (FindNoCase("jasperreportss", classpath) LTE 0)
{
classpath = classpath & ";C:\CFUSIONMX7\wwwroot\WEB-INF\lib\bsh-1.3.0;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-beanutils-1.7.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-collections-2.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-digester-1.7.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-api-1.0.4.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-1.0.4.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\iReport-utils-2.0.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\itext-1.3.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jasperreports-2.0.2.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcmdline-1.0.2.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcommon-1.0.0.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\poi-2.5.1-final-20040804.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\sqljdbc.jar;";
system.setProperty("java.class.path", classpath);
}
clazz = CreateObject("java", "java.lang.Class");
clazz.forName("sun.jdbc.odbc.JdbcOdbcDriver");
driverManager = CreateObject("java", "java.sql.DriverManager");
conurl = "jdbc:odbc:test;user=sa;password=userpassword";
connection = driverManager.getConnection(conurl);

jasperCompileManager = CreateObject("java", "net.sf.jasperreports.engine.JasperCompileManager");
jasReport = JasperCompileManager.compileReport("C:\Inetpub\wwwroot\jasperReport\test.jrxml");

jasFillManager=CreateObject("java","net.sf.jasperreports.engine.JasperFillManager");

parameters = CreateObject("java", "java.util.HashMap");
parameters.put("ReportTitle", "Basic JasperReport");

jasperPrint = jasFillManager.fillReportToFile(jasReport,parameters, connection);
JasperExportManager=CreateObject("java","net.sf.jasperreports.engine.JasperExportManager");

JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\Inetpub\wwwroot\jasperreports\test.pdf");
connection.close();

</cfscript>
<H3>Success!</H3>

i m getting error in compiling the jrxml file. this is the error what i m getting -

inconvertible types found : int required: java.lang.Integer value = (java.lang.Integer)(1)

so i changed my code little bit i tried with the compiled .jasper file created by jasper studio. code for this change is -

<cfscript>
system = CreateObject("java", "java.lang.System");
classpath = system.getProperty("java.class.path");
if (FindNoCase("jasperreportss", classpath) LTE 0)
{
classpath = classpath & ";C:\CFUSIONMX7\wwwroot\WEB-INF\lib\bsh-1.3.0;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-beanutils-1.7.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-collections-2.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-digester-1.7.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-api-1.0.4.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\commons-logging-1.0.4.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\iReport-utils-2.0.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\itext-1.3.1.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jasperreports-2.0.2.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcmdline-1.0.2.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\jcommon-1.0.0.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\poi-2.5.1-final-20040804.jar;C:\CFUSIONMX7\wwwroot\WEB-INF\lib\sqljdbc.jar;";
system.setProperty("java.class.path", classpath);
}
clazz = CreateObject("java", "java.lang.Class");
clazz.forName("sun.jdbc.odbc.JdbcOdbcDriver");
driverManager = CreateObject("java", "java.sql.DriverManager");
conurl = "jdbc:odbc:test;user=sa;password=userpassword";
connection = driverManager.getConnection(conurl);

jasperFile="/jasperReport/test.jasper";
jasLoader=CreateObject("java","net.sf.jasperreports.engine.util.JRLoader");
clsLoader = CreateObject("java", "java.lang.ClassLoader");
jasReport = jasLoader.loadObjectFromLocation(jasperFile,clsLoader);

jasFillManager=CreateObject("java","net.sf.jasperreports.engine.JasperFillManager");

parameters = CreateObject("java", "java.util.HashMap");
parameters.put("ReportTitle", "Basic JasperReport");

jasperPrint = jasFillManager.fillReportToFile(jasReport,parameters, connection);
JasperExportManager=CreateObject("java","net.sf.jasperreports.engine.JasperExportManager");

JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\Inetpub\wwwroot\jasperreports\test.pdf");
connection.close();

</cfscript>
<H3>Success!</H3>

but using this .jasper file i m still getting error which is -

The report template C:\Inetpub\wwwroot\jasperReport\test.jasper appears to be malformed or contain errors.


Pls help me what can be done here. Or any one know how to integrate jasper report in cold fusion. Pls post any successful running code here.

Thanks
rgupta
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1