"Document has no pages" on iReport and nothing on OpenReports - jasper-reports

I am having an issue with JasperReports I can not solve. I am using Eclipse, OpenReports 3.2 and IReport 3.7
The issue I am having is that the report does nothing. When I preview the report in IReport I can at least get a "Document has no pages" message but when I try to open it using OpenReports it doesn't do anything. I get the open reports header and the copyright message but nothing between them.
I was able to track it down to line 150 in ReportRunAction.java in OpenReports. That line is:
jasperPrint = jasperEngine.fillReport(reportInput);
At least that is the line the page dies on. It trips the catch block that the line is inside of but the error is empty. When I try to print the description it is null. I can't swear that the issue isn't that parameter. Through looking around all I have been able to find is something about how the report needs to be compiled with the same version of the jasperreports.jar that OpenReports uses. I have no idea how to tell if/what version of jasper reports is being bundled into the .jasper file though.
Is that my problem? If so how do I tell/set the version of the jar that gets bundled? If not; help!

The no pages messages comes out when the report has not records or you discarded all of them with a wrong filter expression.
There are a couple of things you can try:
set the filter expression to:
new Boolean (true)
This will in some way reset your filter expression.
Right click your jasper report
properties
find more...
and Set the report property "When no data" to "All sections no details" so you can see at least the rest of the report.
Thanks.

If you are using the Detail Bandeport, then you will need a Data Query for the report. Since it's returning "No Pages" in iReport, then you either don't have a query. Or simply your query is not returning any rows.
In old iReport, from Data menu, choose Report Query and write your query here. If you want only one record (i.e. Detail band only one time) you can use a dummy table. Like:
SELECT 'a' FROM DUMMY
Otherwise, if you don't want to use the Detail Band, you have the option to view the other bands without using a query. From Edit menu, choose Report Properties, under More... tab, set the flag When no data to All Sections, no detail
Your problem is not exceptions or errors, it's just no data to show.

Any Empty Datasource will do the trick too.

I ran into the same error when using IReports when I had a subreport that only contained other subreports and no actual query. Adding a dummy query as medopal suggests fixes the no pages error and allows things to run correctly.
See also: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=49315

I've been facing this error for a while. In my case, this error occurred because of an image. If you have images in your report file, you will be forced to fill image with valid data when you wanna use report. If you don't, you will see this error "Document has no page". To address this problem just set "on error type" field in properties window (just click on image you'll see the property window) to "blank".
Strong wish.

I had same problem and got after searching problem, that I did not provide password to connection.
so I add these lines to my java code.
Class.forName("com.mysql.jdbc.Driver");
con =DriverManager.getConnection("jdbc:mysql://localhost:3306/stock_mngt","root","your password");
now my code works.

Related

Crystal Reports - suppress subreport parameter prompts

I have a Crystal report with several subreports linked on a common field - all working great. Now must add another, very complex, existing report as a new sub. This report's data source code stretches several pages. It also has over a dozen parameters which are further imbedded in numerous formula fields through out. That said, it runs fine and has a parameter that links with the main report. Unfortunately all the other parameter prompts is supremely annoying.
I've searched high and low for a method to accept default values without prompts but Crystal doesn't seem to accommodate that notion.
Revising the report to remove all the unneeded parameters would be extremely painful and simply not an option.
I'm hoping to find an alternate way to pass the parameter values to prevent the prompt. I'm aware of the SetParameterValue() method of the ReportDocument class but not sure how to use it. I've found examples of how to use it with C#, VS, ASP.net, etc., none of which work for an end user like myself.
Could the data source command itself be used?
Much thanks for any recommendations, guidance or thoughts!
With Command Level prompts, you would never be able to change the prompt values with the CR Viewer.
If the report is supposed to be viewed in the CR Viewer and you need the functionality or changing prompt values, try this:
1) Remove Command Level prompts
2) Create the Data prompt in the report from the Field Explorer
3) Create a Record Selection formula like this:
{date_field} = {?Date_prompt}
under Report > Selection Formulas > Saved data
4) Save the report with data
Try this...

JasperReport parameters works in iReport but fails on JasperServer with input control

JasperServer doesn't pass parameter from input control to the report for some unknown reason.
I defined a jrxml report with iReport 4.6 (even tried compatibility mode 4.0.1) using input parameter which works in iReport.
When I deploy the report on jasperserver 4.5 the response I get is "The report is empty".
Same report without parameter works also well.
Naturally I defined and attached input control with single-select query.
The value column and the visible column in input control is the same DB field I use as parameter in jrxml.
Query values as possible input are displayed fine, but when I choose one..."The report is empty"!!.
I tried simplifying the report but my parameter from input control just wont be passed through to render the report.
You must create the parameter in jasperserver too (not only in iReport), with same name.
In JasperServer, edit your report, define "Input controls" with same ids and go thru wizard, it should work now.
If you like to test first select "Always require in emergin window".
You can also look at the answer here http://jasperforge.org/node/543148

Deploying subreports in JasperServer

I have created a frame and subreport for integration with APEX and refined to the point I am ready to deploy on JasperServer. Somehow the exact syntax is defeating me. I've tried all the variations the following questions would indicate, but nothing seems to work. I'm using Glassfish, btw, but I don't think that is significant. Here are my questions:
When deploying the subreport, do I deploy as a report or as a JRXML file?
Do I need to set up Input Controls for the subreport, as passed by the frame report?
Does it matter where I deploy the subreport (folder structure) so long as I am passing the correct SUBREPORT_DIR parameter to the frame?
On that SUBREPORT_DIR, I've tried a couple different things. First I had the default as an absolute path on my local box, for debugging purposes, and was passing the value I wanted in the URL (i.e. ...&SUBREPORT_DIR=/Subreports/...). I also tried setting the default to the path I wanted. Neither works, but should the former work as well as the latter?
What's the actual syntax for passing SUBREPORT_DIR? I've deployed my frame report as "/reports/frame" and my subreport as "/reports/Subreports/sub", so I was passing "repo:/Subreports/" (without quotes in the URL, with quotes in the default on frame).
My frame and sub work in iReport with the same params I'm passing, but they don't work from the URL at all. I can load up the sub as a report under JasperServer, pass it the params frame passes, and get it to work, but when I try to run the frame, no dice.
Thanks in advance for all the help, and I hope to pay it back once I get this properly configured.
OP's findings.
The subreport needs to be deployed in the repository as a JRXML file. It will say "File" in the appropriate column of the repository view.
You do NOT need to set Input Controls for the subreport. The frame report needs only those Input Controls that it utilizes, not the subreport parameters.
As long as you pass the correct SUBREPORT_DIR, you can put the subreport anywhere you want, but remember that the frame report will reference the sub by exactly the name you specify. One of my two problems (see #1 above for the other) was specifying an extension in the default path. This was correct in iReport, but wrong on the server side.
SUBREPORT_DIR can be passed as a parameter and works as advertised.
The correct path for SUB_REPORT_DIR, which I am using now as a defaulted param, is something like "repo:/reports/Subreports/". The Subreport Expression under detail is therefore: $P{SUBREPORT_DIR} + "five_col_sub". See #3 above.
Not that tricky, really, but also not completely intuitive. My colleague pointed out that "repo: " is short for the JasperServer Repository. Seems obvious now, but I was assuming it meant "reports", necessitating that any report with a subreport and the subreport itself would have to exist under the /reports/ directory, which is not the case.

Linking subreports in iReport so they also work in Jasper server

Using iReport v4.0.1 with Jasperserver v4.1.0 I'm trying to find a syntax for linking subreports to the main report that lets me test it in iReport then deploy to the server through the repository browser.
The default syntax for sub-reports in iReport for the subreport expression is something like
$P{SUBREPORT_DIR} + "mySubReport.jasper"
When you deploy this from iReport it's smart enough to pick this up and suggest changing it to
"repo:mySubReport.jrxml"
and to then deploy all subreports to the Resources folder of the main report.
That's great, but unfortunately it then edits the file in iReport to save this change which means you can no longer run the report in iReport without manually re-editing all the sub-report expressions - this makes the process of testing and deploying to the server really painful, particularly when there are multiple sub-reports in a report.
I thought I could at least set the value of $P{SUBREPORT} to be "repo:" or "My\local\filepath" so that at least I'd only have one place to change it, but the compiler doesn't like that.
Is there an alternative structure or an expression that will resolve to repo:*.jrxml or My\local\filepath*.jasper correctly depending on where you're running the report from?
The best solution to this is to add an additional parameter like $P{IsOnServer}. Set the default value to true. For your subreport expression use this:
$P{IsOnServer} ? "repo:mySubReport.jrxml" : "/local/path/to/mySubReport.jasper"
When you run the report in iReport, you'll be prompted for the value of IsOnServer. Make it false; the subreport expression will resolve to your local file. On the server, don't define an input control. The users will never be prompted for that parameter (they won't even know it exists), and it will result to the desired 'repo' syntax.
An even better solution would of course be for iReport to handle this automatically... but for now you need to do something like this.

Subreport not displaying data

My Crystal Report is generated in Visual Studio 2008. I've linked the subreport parameters and everything runs fine when I run it from the report previewer within visual studio.
But when I deploy the report to the production server, the sub-reports don't have any data at all, even though the main data runs fine. What might be causing the subreports to stop working on the production server?
Did you check DataSources for main report and sub report?
Did you check if sub report is embedded in the main report?
Did you deploy the Sub report if it is not embedded?
How many and what kind of parameters do you use Dates, Strings, Integers ...
What is the error do you get? This should give you some directions where to look for a problem.
Can you try some other sub reports instead of the failing one.
And finally, use the old computer trick. Remove the sub report and then create/embed it again.
Right click your subreport
Open "Change Subreport Links"
Make sure you have chosen one field from the "Available fields" section.
In case you have parameters in your report:
Have you tried showing the report from code instead of previewer? Is that different? If yes then probably there's a mismatch between your data input from code and previewer
I was facing same issue and changed my code from this:
for (int i = 0; i < SbRptDtSrcs.Count; i++)
{
rpt.Subreports[i].SetDataSource(SbRptDtSrcs[i]);
}
to:
rpt.Subreports["rpt1.rpt"].SetDataSource(SbRptDtSrcs[0]);
rpt.Subreports["rpt2.rpt"].SetDataSource(SbRptDtSrcs[1]);
and it worked.