Reputation: 41
I have a subreport which I have used in my main jasper report, I am sending the subreport from a java form using an InputStream
, this is the code:
InputStream suprepo = getClass().getResourceAsStream("LinuxTest_subreport1.jasper");
And in the main report I have create a parameter that's class is InputStream
, and accepting the value from my java form that I'm passing using a hashmap.
My problem is that everything works fine when there is only 1 page, but as soon as there is more then one page I receive this error:
error in loading object from input stream
This is my jasper code
<parameter name="subrepopath" class="java.io.InputStream" isForPrompting="false"/>
Upvotes: 4
Views: 21587
Reputation: 359
I had the same issue, and it was caused by a subreport (.jasper) compiled with other version of the Jasper Report.
Upvotes: 3
Reputation: 3189
I also suffered from this issue and just recently found the solution thanks to this post.
What you need to do is change your subreport type to Object:
<parameter name="subrepopath" class="java.lang.Object" isForPrompting="false"/>
In your SubReport properties, set the Expression class to be:
net.sf.jasperreports.engine.JasperReport
In your code, you need to load the object into a JasperReport object, this is where I differ from the linked page as the methods used are deprecated.
So you would do:
InputStream suprepo = getClass().getResourceAsStream("LinuxTest_subreport1.jasper");
JasperReport subJasperReport = (JasperReport)JRLoader.loadObject(suprepo);
Then add in your parameter map the object subJasperReport
with the key of subrepopath
and you'll find your multi page report will now generate correctly.
Upvotes: 0