Very misleading exception stacktrace when an image file is not found at runtime
Situation: Using the BIRT runtime on a Linux system (with case-sensitive filenames). The report contains an image where the image filename is read from the database. The report expects the image as eg. "../logos/logo_na.jpg", but there is only a file called "../logos/logo_NA.jpg".
Note that the URL does not contain a "file:" protocol.
Note: The filename expression is more complicated in reality (as seen in the screenshot), but "../logos/logo_na.jpg" is the exppression result.
An error message that I would prefer to see in the log would be something like "Image file ../logos/logo_na.jpg not found".
Instead, at runtime I get the following stack trace:
BIRT runAndRenderTask error org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report. at org.eclipse.birt.report.engine.api.impl.EngineTask.handleFatalExceptions(EngineTask.java:1867) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:153) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:69) at com.tp.server.lisa.birt.report.BirtReportGenerator.run(BirtReportGenerator.java:444) Caused by: java.lang.IllegalArgumentException at java.base/sun.net.www.ParseUtil.decode(ParseUtil.java:204) at java.base/sun.net.www.protocol.file.Handler.openConnection(Handler.java:80) at java.base/sun.net.www.protocol.file.Handler.openConnection(Handler.java:72) at java.base/java.net.URL.openConnection(URL.java:1094) at java.base/java.net.URL.openStream(URL.java:1161) at org.eclipse.birt.report.model.util.ResourceLocatorImplBase.tryURLSearch(ResourceLocatorImplBase.java:260) at org.eclipse.birt.report.model.util.ResourceLocatorImplBase.tryURLSearch(ResourceLocatorImplBase.java:236) at org.eclipse.birt.report.model.util.ResourceLocatorImplBase.getResource(ResourceLocatorImplBase.java:188) at org.eclipse.birt.report.model.util.ResourceLocatorImplBase.findResource(ResourceLocatorImplBase.java:80) at org.eclipse.birt.report.model.core.ModuleImpl.findResource(ModuleImpl.java:1214) at org.eclipse.birt.report.model.api.ModuleHandleImpl.findResource(ModuleHandleImpl.java:2056) at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localizeImage(LocalizedContentVisitor.java:608) at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localize(LocalizedContentVisitor.java:169) at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:36) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:62) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:27) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:133) at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resumeLayout(HTMLInlineStackingLM.java:97) at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layoutNodes(HTMLInlineStackingLM.java:136) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:27) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:133) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:27) at org.eclipse.birt.report.engine.layout.html.HTMLRepeatHeaderLM.layoutChildren(HTMLRepeatHeaderLM.java:54) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:133) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:27) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:133) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:27) at org.eclipse.birt.report.engine.layout.html.HTMLRepeatHeaderLM.layoutChildren(HTMLRepeatHeaderLM.java:54) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:133) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:27) at org.eclipse.birt.report.engine.layout.html.HTMLListLM.layoutChildren(HTMLListLM.java:68) at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:133) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92) at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:97) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:145) ... 2 more
By looking at the stacktrace, I could only guess that the error is related to an image in the report (from the line containing localizeImage).
But why should there be an java.lang.IllegalArgumentException in parsing the URL?
I could not find current source code for the sun.net.www.ParseUtil class. I only found an older version, and there it seems like this IllegalArgumentException without detailed information is caused by an invalid % escape sequence.
But our file name does not contain any percent symbols, so what happens here?
Note: The report is running on a Czech computer at the customer's site; maybe some at some place an error message with non-ASCII characters is treated as a URL? I cannot debug it there, and I'm not able to reproduce it in the IDE.