Jump to content
JasperReports Library 7.0 is now available ×

lzqweasz

Recommended Posts

package abc;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.InputStream;import java.sql.*;import net.sf.jasperreports.engine.*;import net.sf.jasperreports.engine.design.JasperDesign;import net.sf.jasperreports.engine.export.*;import net.sf.jasperreports.engine.xml.JRXmlLoader;import net.sf.jasperreports.view.JasperViewer;public class JasperReport {public static void main(String[] args) {  // TODO Auto-generated method stub  String url = "XXX";  String user = "XXX";  String pwd = "XXX";  try {   Connection connRead = DriverManager.getConnection(url, user, pwd);   String address = "C:\JaspersoftWorkspace\MyReports\First.jrxml";   InputStream inputStream = new FileInputStream (address);   JasperDesign jasperDesign = JRXmlLoader.load(inputStream);   net.sf.jasperreports.engine.JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);   JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, connRead);   JasperExportManager.exportReportToPdfFile(jasperPrint, "c:/A/test_jasper.pdf");   JasperViewer.viewReport(jasperPrint);  } catch (SQLException | JRException | FileNotFoundException e) {   // TODO Auto-generated catch block   e.printStackTrace();  }   }}[/code]
Exception in thread "main" java.lang.ClassCastException: [Lnet.sf.jasperreports.engine.type.CalculationEnum; cannot be cast to [Lnet.sf.jasperreports.engine.type.NamedEnum; at net.sf.jasperreports.engine.xml.XmlConstantPropertyRule.<init>(XmlConstantPropertyRule.java:47) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.addDatasetRules(JRXmlDigesterFactory.java:1214) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.configureDigester(JRXmlDigesterFactory.java:507) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1438) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:262) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:247) at abc.JasperReport.main(JasperReport.java:28)[/code]

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

package abc;

 

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.InputStream;

import java.sql.*;

 

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.engine.design.JasperDesign;

import net.sf.jasperreports.engine.export.*;

import net.sf.jasperreports.engine.xml.JRXmlLoader;

import net.sf.jasperreports.view.JasperViewer;

public class JasperReport {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

 

String url = "XXX";

String user = "XXX";

String pwd = "XXX";

try {

Connection connRead = DriverManager.getConnection(url, user, pwd);

String address = "C:\JaspersoftWorkspace\MyReports\First.jrxml";

InputStream inputStream = new FileInputStream (address);

JasperDesign jasperDesign = JRXmlLoader.load(inputStream);

net.sf.jasperreports.engine.JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, connRead);

JasperExportManager.exportReportToPdfFile(jasperPrint, "c:/A/test_jasper.pdf");

JasperViewer.viewReport(jasperPrint);

} catch (SQLException | JRException | FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

 

}

 

}

 

Link to comment
Share on other sites

one more error, 

this morning I try to set the report data from HashMap, 

the error change to 

 

net.sf.jasperreports.engine.JRException: Error compiling report java source files : I:Java SAPSecondJasperreportFirst_1416963786573_878040.java I:Java SAPSecondJasperreportFirst_tableDataset_1416963786573_878040.java

 

I have no idea about those files.

 

Anyway, 

 

Exception in thread "main" java.lang.ClassCastException:[Lnet.sf.jasperreports.engine.type.CalculationEnum; cannot be cast to[Lnet.sf.jasperreports.engine.type.NamedEnum; at net.sf.jasperreports.engine.xml.XmlConstantPropertyRule.<init>(XmlConstantPropertyRule.java:47) at 

 

How can I fix those two question?

Please help.

Thanks.

Link to comment
Share on other sites

Finally, I export my first Jasper Report. 

I dont how to fix it.

The solutions is remove all the Jar and re-add.

 

Here is my environment(Only use Jasperreport).

Win 7

Eclipse IDE for Java and Report Developers
Version: Luna Release (4.4.0)
Build id: 20140612-0600
 
 
JAR List
jasperreports-5.6.1.jar
jasperreports-chart-themes-5.6.1.jar
jasperreports-fonts-5.6.1.jar
jasperreports-functions-5.6.1.jar
mysql-connector-java-5.1.9.jar
commons-digester-1.7.jar
commons-logging-1.1.jar
org.apache.commons.collections_3.2.0.v2013030210310.jar
joda-time-2.0.jar
commons-beanutils-1.8.3.jar
iTextAsianiTextAsian.jar
jasper-compiler-jdt.jar
com.lowagie.text_2.1.7.v201004222200.jar
poi-3.5-FINAL.jar
iText-2.1.7.js2.jar
****Download from here : http://www.java2s.com/
 
Link to comment
Share on other sites

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...