arianhojat Posted September 24, 2007 Share Posted September 24, 2007 Hello all, I am getting an error when trying to display my reports online (oddly going through ireports to see the whole report seems to be no problem though): net.sf.jasperreports.engine.JRException: Could not load object from location : sub1.jasper If I take my subreports out of the main jrxml file, the main report shows up on my jsp page. I was wondering if maybe I was doing something wrong in the way i reference the file? Here is a subreport reference in main jrxml file: <subreport isUsingCache="true"> <reportElement x="23" y="32" width="504" height="31" key="subreport-1" isRemoveLineWhenBlank="true"/> <subreportParameter name="empnumber"> <subreportParameterExpression><![CDATA[$F{empnumber}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression class="java.lang.String"><![CDATA["sub1.jasper"]]></subreportExpression> </subreport>Post edited by: arianhojat, at: 2007/09/24 16:37 Link to comment Share on other sites More sharing options...
arianhojat Posted September 25, 2007 Author Share Posted September 25, 2007 hmmm it seems like i have to use whole path.for example, this works:<subreportExpression class="java.lang.String"><![CDATA["C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/webapp/reports/sub1.jasper"]]></subreportExpression> hmmm should i change all my references to full file paths? or pass in a parameter to use in the report like so:parameters.put("sub1FilePath", application.getRealPath("/reports/sub1.jasper")); but then ireports wont know what to do. So basically could I setup something like this in jrxml file:if(isset($P{sub1FilePath}))<subreportExpression class="java.lang.String"><![CDATA["$P{sub1FilePath}"]]></subreportExpression>else<subreportExpression class="java.lang.String"><![CDATA["sub1.jasper"]]></subreportExpression>Post edited by: arianhojat, at: 2007/09/24 17:27 Link to comment Share on other sites More sharing options...
arianhojat Posted September 25, 2007 Author Share Posted September 25, 2007 update: i learned that all references including subreports/images/fonts should be referenced relative to their location within the classpath, so they can work no matter how deployed... Now what this means i am unsure, since the 'classpath' to me is system dependant, and my jasper reports could move from different boxes, iod rather just it be smart and do relative to current dir report is in ;). thinking about it more,Basically: Want it so subreport references will work relatively if using ireports or tomcat web app.Post edited by: arianhojat, at: 2007/09/24 20:39 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now