I'm getting an error while trying to use a jrxml file with a subreport in JasperServer. This seems like a pretty basic problem, but I've been searching for a long time and can't find out what I'm doing wrong. I appreciate any help or direction you can offer.
I have a main report: "dashboard2.jrxml", that includes a compiled subreport: "yearoveryear_graph_sm.jasper". Both live in my home directory. There's no problem passing parameters and seeing results when I preview dashboard2.jrxml in iReport. However, my new JasperServer report that's based on dashboard2.jrxml has a problem with the subreport.
I get this error in the JasperServer report:
com.jaspersoft.jasperserver.api.JSExceptionWrapper: Could not load object from location : yearoveryear_graph_sm.jasper
When the subreportExpression of dashboard2.jrxml is this:
(I've tried variations of including the path and using a string parameter instead of text itself, but came up with the same bad results.)
1. Do I just need to find a better place for that subreport .jasper file where JasperServer can find it?
Seems likely, as it's currently in my home directory, but I have no idea where to put it.
2. Is the subreportExpression class wrong? Should it not be a String?
I made a failed blind attempt. When the subreportExpression of dashboard2.jrxml looks like this:
<subreportExpression class="net.sf.jasperreports.engine.JasperReport"> <![CDATA[JasperCompileManager.compileReport(net.sf.jasperreports.engine.xml.JRXmlLoader.load(getClass().getResourceAsStream("yearoveryear_graph_sm.jrxml")))]]>
Again, the report previews fine in iReport, but I get this error when I try to use it in JasperServer:
com.jaspersoft.jasperserver.api.JSExceptionWrapper: Error evaluating expression : Source text : JasperCompileManager.compileReport( net.sf.jasperreports.engine.xml.JRXmlLoader.load(getClass().getResourceAsStream( "yearoveryear_graph_sm.jrxml" )))
Full jrxml and error text are attached.
Apache Tomcat 5.5
Thanks in advance!
Post Edited by jolie600 at 10/16/2009 20:11
I added "repo:" to the subreportExpression:
JasperServer then prompted me to add the resource yearoveryear_graph_sm.jasper to the JasperServer report, which I successfully did.
And now I'm getting this error:
com.jaspersoft.jasperserver.api.JSExceptionWrapper: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
Post Edited by jolie600 at 10/16/2009 20:10
Solved. For anyone stumbling across this thread, this is how I solved my own compounded problem(s).
I ended up with this in my mainreport.jrxml:
In the Design window, the Subreport Expression property is "repo:subreportname", including double quotes. iReport will not Preview the jrxml like this (it says "Unable to locate the subreport with expression ""subreportname"".").
I then based a JasperServer report on the mainreport.jrxml.
While editing the JS report, JS prompted me to upload a Resource called subreportname. It wants the subreport jrxml file, NOT the .jasper file. That mistake is what was causing this error: com.jaspersoft.jasperserver.api.JSExceptionWrapper: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
It took me a ridiculously long time to figure out these issues, so hopefully this explanation helps someone else.
Post Edited by jolie600 at 10/16/2009 20:12
When I publish a report containing a subreport from iReport using the repository navigator there is a dialog box that displays the modified path for your subreport. It changes your main.jrxml to contain repo: for the subreport element. That works fine until you change something in the main report and just update it. in that case it doesn't change the jrxml to include repo: and now you get the object could not be loaded error. I'm having to drop the report entirely on JS and republish it each time. Only takes a few seconds but that's my work around.
Right now my issue is that it's not aware of a nested subreport when it publishes. That means your main.jrxml is changed to include repo: for the subreport it has but the subreport's jrxml is not modified for it's contained subreport. Does that make sense? I added bugtrackers for both issues. Not sure this helps but just know that you're not alone in this regard.
For example, your parent report would have a link to the subreport like so:
That caused me a lot of grief.
Has this changed any in subsequent releases? I seem to have followed the instructions correctly ...
- I built my report making sure everything lines up right.
- I viewed the XML file, making the appropriate changes
- I click the Compile Button (or preview)
After that, I get the following exception:
java.lang.Exception: repo:subreport1 not found.
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) ...
Error filling print... Could not load object from location : repo:subreport1
net.sf.jasperreports.engine.JRException: Could not load object from location : repo:subreport1
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:263) ...
all the solutions above are not working or clearly defining what to do in using designer preview and server functionality: see here for details how to solve it: http://stackoverflow.com/a/20374515/1915920