[#10771] - Exception: Unknown entity if path has whitespaces

Category:
Bug report
Priority:
Urgent
Status:
Feedback Requested
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
1

I am compiling reports programatically in Java. This works fine except if there are whitespaces in the path of my application.

Here is the method that gets the exception:

public void setCustomizeClassInReport(URL report, String parameterName, String groupName) {
try {
JasperDesign jd = JRXmlLoader.load(report.openStream());
setCustomizerClass(jd, groupName);
JasperReport jr = JasperCompileManager.compileReport(jd);
getReportparameter().addReportparameter(parameterName, jr);
} catch (Exception e) {
e.printStackTrace();
}
}

I attached 2 screenshots of the debugger showing the problems. In the method
net.sf.jasperreports.engine.xml.JRXmlDigester.resolveEntity(String, String)
on line 220
the entityUrl collections contains allowed paths which contain whitespaces. The systemId is checked if it is contained in the collection. But the systemId path has %20 instead of whitespaces. That's why an exception is thrown. I hope you understand what I mean.

AttachmentSize
PDF icon 2018-04-19_15h44_17.pdf58.55 KB
JasperReports
matze's picture
6
Joined: May 15 2011 - 10:16pm
Last seen: 7 months 4 days ago

3 Comments:

#1
  • Assigned:nobody» lucianc
#2
  • Priority:Normal» Urgent

We attempted to upgrade to the latest release and ran into the same exact issue as the posted above. Until this item is fixed, the following is the workaround we are using.

DefaultJasperReportsContext.getInstance().setProperty(
"net.sf.jasperreports.xml.load.unknown.entities", "true");

#3
  • Status:New» Feedback Requested

I made a test and it worked fine for me. See attached screenshot, entityURLs contained URLs with spaces encoded as %20 just like systemId.

I suspect that the problem in your case is that you have a classloader whose getResource method (called by JRXmlDigester.addEntityResource via JRLoader.getResource) returns invalid URLs for paths with spaces. Spaces should be encoded in URL paths.

Can you create a self contained test case to reproduce the problem so that we can fully understand what's going on?

AttachmentSize
Image icon jr-debug.png49.38 KB
Feedback
randomness