Subreport: Could not load object from location

0

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:
    <subreportExpression class="java.lang.String">
        <![CDATA["yearoveryear_graph_sm.jasper"]]>
    </subreportExpression>

(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")))]]>
    </subreportExpression>

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.

iReport 3.6.0
JasperServer 3.5
Linux
Apache Tomcat 5.5

Thanks in advance!

..Jolie



Post Edited by jolie600 at 10/16/2009 20:11
jolie600's picture
Joined: Jun 4 2009 - 11:02am
Last seen: 10 years 6 months ago

8 Answers:

0

Progress....maybe.

I added "repo:" to  the subreportExpression:

    <subreportExpression class="java.lang.String">
        <![CDATA["repo:yearoveryear_graph_sm.jasper"]]>
    </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.

 

..Jolie



Post Edited by jolie600 at 10/16/2009 20:10
jolie600's picture
Joined: Jun 4 2009 - 11:02am
Last seen: 10 years 6 months ago
0

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:

    <subreportExpression class="java.lang.String">
        <![CDATA["repo:subreportname"]]>
    </subreportExpression>

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.

..Jolie



Post Edited by jolie600 at 10/16/2009 20:12
jolie600's picture
Joined: Jun 4 2009 - 11:02am
Last seen: 10 years 6 months ago
0

It helped me - Thanks! 

So it appears that to do this, you first get everything working in iReports, then before sending it up to the JasperServer you need to change the expression by adding "repo".

dknutson's picture
Joined: Oct 4 2006 - 7:26am
Last seen: 4 years 6 months ago
0
This is the point we're at now but there has to be a way to set the value so that it works both locally and on the server
richmaneri's picture
Joined: Nov 12 2009 - 8:39am
Last seen: 1 year 6 months ago
0

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.

manshack_one's picture
Joined: Aug 18 2009 - 9:29am
Last seen: 2 years 8 months ago
0
Just to point out that the "repo:" bit of "repo:subreportname" is LITERALLY "repo:", and not your actual repository location. Whereas the "subreportname" bit is of course your subreport name with ".jrxml" extension rather than with the ".jasper" extension that you'd normally use with iReports.

For example, your parent report would have a link to the subreport like so:
<subreportExpression class="java.lang.String"><![CDATA["repo:my_subreport.jrxml"]]></subreportExpression>

That caused me a lot of grief.
shanmei's picture
Joined: Nov 9 2009 - 6:37pm
Last seen: 10 years 1 month ago
0

 Has this changed any in subsequent releases? I seem to have followed the instructions correctly ...

  1. I built my report making sure everything lines up right. 
  2. I viewed the XML file, making the appropriate changes
  3. I click the Compile Button (or preview)

After that, I get the following exception:

java.lang.Exception: repo:subreport1 not found. 
    at com.jaspersoft.ireport.designer.utils.Misc.locateFileFromExpression(Misc.java:1374) 
    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.compileSubreports(IReportCompiler.java:1418) 
    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:509) 
    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.util.JRLoader.loadObjectFromLocation(JRLoader.java:262) 
    at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:301) 
    at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:327) 
    at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:263)  ...

Any thoughts?

 

 

zhanng's picture
25
Joined: Apr 8 2011 - 9:02am
Last seen: 8 years 8 months ago
0

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

andreasX's picture
Joined: Nov 8 2013 - 2:31am
Last seen: 2 years 8 months ago
Feedback