Jasper reports can use external templates and subreports referred in .jrxml file as follows:
<template><![CDATA["repo:template.jrtx"]]></template>
<subreportExpression><![CDATA["repo:subreport.jrxml"]]></subreportExpression>
This works perfectly when run on the Jasper server, but when launched in-process from Java Code it returns errors like:
net.sf.jasperreports.engine.JRException: Resource not found at : repo:template.jrxml
at net.sf.jasperreports.repo.RepositoryUtil.getResourceFromLocation(RepositoryUtil.java:255)
at net.sf.jasperreports.repo.RepositoryUtil.getReport(RepositoryUtil.java:208)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:329)
In Jasper designer resources are added to Resources list that is not stored within the report file. How can I do the same with RepositoryUtil? I.e. tell RepositoryUtil to replace “repo” with some real location? The code I use:
Connection conn = ... ;
String reportSource = "C:\\report.jrxml";
Map<String, Object> params = new HashMap<String, Object>();
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn);
That’s certainly a classpath issue
Jasper tries to load resources firstly as an absolute path, then as a relative path through the app classpath
You can try to cope wih absolute paths for templates and subreports, it should work
You can try also to put the resource directory in the classpath of the app with a
-cp "/path/to/resourceDir/*"