Jump to content

Subreport: Could not load object from location


Recommended Posts

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

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

iReport 3.6.0
JasperServer 3.5
Apache Tomcat 5.5

Thanks in advance!


Post Edited by jolie600 at 10/16/2009 20:11
Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic


I added "repo:" to  the subreportExpression:

    <subreportExpression class="java.lang.String">

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
Link to comment
Share on other sites

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

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
Link to comment
Share on other sites

  • 3 weeks later...

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.

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

  • 1 year later...

 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?



Link to comment
Share on other sites

  • 2 years later...

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