Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

could not load load from location:/test_subreport.jasper  RSS feed

 
John Smith
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All:

Any help or hint is greatly appreciated it!!
I am currently using IceFaces 1.8.2, Jsf 1.1, and JasperReport 3.5.2.
I get the following error:
net.sf.jasperreports.engine.JRException: Could not load object from location : /test_subreport.jasper
The report test_report.jasper has a subreport called test_subreport.jasper. I placed both test_report.jasper and test_subreport.jasper in the directory "WEB-INF/reports/"


public String testSearch() throws Exception
{
try
{
Connection connection;
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
InputStream reportStream = context.getExternalContext().getResourceAsStream("WEB-INF/reports/test_report.jasper");
ServletOutputStream servletOutputStream = response.getOutputStream();
ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
String filepath = ctx.getRealPath("/WEB-INF/reports/");
filepath = filepath = "/";
String imagepath = ctx.getRealPath("/WEB-INF/images/test_logo.gif");

HashMap parameterMap = new HashMap();


parameterMap.put("SUBREPORT_DIR", filepath);
parameterMap.put("Test Number", testNumber);
parameterMap.put("Image Path", imagepath);

Properties properties = new Properties();
properties.load(context.getExternalContext().getResourceAsStream("WEB-INF/config.properties"));

String driver = properties.getProperty("jdbc.driver");
String jdbc_url = properties.getProperty("jdbc.url");
String username = properties.getProperty("jdbc.username");
String password = properties.getProperty("jdbc.password");
Class.forName(driver);
connection = DriverManager.getConnection(jdbc_url, username, password);


JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, parameterMap, connection);
//byte[] reports = JasperRunManager.runReportToPdf(reportStream, parameterMap, connection);
connection.close();
response.setContentType("application/pdf");
servletOutputStream.flush();
servletOutputStream.close();
}
catch(Exception e)
{
log.error("exception message:"+e.getMessage());
}

return "success";
}
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Not sure... but can you add a forward slash on your WEB-INF? like this.


 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@John,
After 47 posts, one would expect, that you would know by now, to UseCodeTags
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:@John,
After 47 posts, one would expect, that you would know by now, to UseCodeTags


I dunno, Maneesh. I was probably equally slow to take the hint.

On the other hand, asking what amounts to the same question more than once is something we discourage. There's a FAQ for that, I believe.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!