Jump to content
JasperReports Library 7.0 is now available ×

Error displaying a simple report


Recommended Posts

By: Alex - a_sc

Error displaying a simple report

2006-03-21 23:47

Hello!

 

I am making my first steps with JasperReports, so I tried to keep things simple and created a basic report with iReport that just has some static text in the title band and no other data. Previewing the report in iReport works fine, but when I try to display the report in my own Swing application using the following command

 

JasperViewer.viewReport("c:\Testreport.jrxml", true);

 

I get the following error:

21.03.2006 13:48:07 org.apache.commons.digester.Digester startElement

SEVERE: Begin event threw exception

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at org.apache.commons.collections.ArrayStack.peek(ArrayStack.java:109)

at org.apache.commons.digester.Digester.peek(Digester.java:2529)

at net.sf.jasperreports.engine.xml.JRPrintElementFactory.createObject(JRPrintElementFactory.java:67)

...

 

I have also tried this:

 

JasperDesign reportDesign = JRXmlLoader.load("C:\Testreport.jrxml");

JasperReport report = JasperCompileManager.compileReport(reportDesign);

JasperPrint print = JasperFillManager.fillReport(report, null);

JasperViewer.viewReport(print);

 

but then I get a MessageBox with a "The document has no pages" message and then an empty JasperViewer is displayed.

 

I am struggling with this problem for some time now and could not find anything about this error in the web. I hope that someone in this forum can help me solve this problem.

 

 

By: Lalith - weeralalith

RE: Error displaying a simple report

2006-03-22 04:07

1. First check whether you have set the class path to "commons-digester.jar"

2. If you are using a quary string in your report you may have to create a connection obj and use it in JasperFillManager.fillReport() method

 

e.g.

Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection("jdbc:oracle:cust","username","password"); // cust is the DSN Name

 

Map map = new HashMap();

map.put("param1","Jacob");

 

jasperReport = JasperCompileManager.compileReport("myreport.jrxml");

jasperPrint = JasperFillManager.fillReport(jasperReport,map,conn);

 

JasperViewer.viewReport(jasperPrint);

 

 

I hope this will help you...

Lalith

 

 

 

By: Alex - a_sc

RE: Error displaying a simple report

2006-03-22 05:23

Hello Lalith!

 

Thank you for your answer! I have commons-digester-1.7.jar in my classpath. Since my simple test-report does not contain any dynamic data but only a static textfield in the title band , I do not use a datasource at all. Could this be the problem? Does JasperReports need a datasource even if there is no dynamic data in the report?

 

 

 

By: Lalith - weeralalith

RE: Error displaying a simple report

2006-03-22 05:45

Hi Alex,

 

Then you may need to use following way

 

jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), new JREmptyDataSource());

 

hope this will help you.

Lalith

 

 

 

By: Alex - a_sc

RE: Error displaying a simple report

2006-03-22 05:53

Yes, that solved my problem. Thank you very much!

 

Greetings,

Alex

 

 

By: Sanjeev Saha - sanjeevsaha

RE: Error displaying a simple report

2006-03-22 05:53

Since there is not data available, you'll need to pass an instance of JREmptyDataSource while filling the report:

 

JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());

 

If the title still doesn't show up, try setting the attribute whenNoDataType="AllSectionsNoDetail".

 

hth,

Sanjeev

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