Image expression URL in Jasper Reports
<![CDATA["../images/company_logo.jpg"]]>
should do the trick. The path is relative to your .jasper file.
With .jrxml when use an absolute path with image, when the packaged jar filr will be deployed you will get:
java.lang.IllegalArgumentException: name
at sun.misc.URLClassPath$Loader.findResource(Unknown Source) ~[na:1.8.0_121]
at sun.misc.URLClassPath.findResource(Unknown Source) ~[na:1.8.0_121]
at java.net.URLClassLoader$2.run(Unknown Source) ~[na:1.8.0_121]
at java.net.URLClassLoader$2.run(Unknown Source) ~[na:1.8.0_121]
Try to load resource as:
<imageExpression><![CDATA[this.getClass().getResourceAsStream("/img/mdg_logo.jpg")]]></imageExpression>
You need to create a PARAMETER of type String called for example CONTEXT, and from your JSP send the servlet context:
parameters.put("CONTEXT",this.getServletContext().getRealPath("/"));
Now, in your report you use the parameter:
$P{CONTEXT}.toString()+"reports/images/logo.png"
The same apply for sub reports or other web resources, example:
$P{CONTEXT}.toString()+"reports/OrdenCompraAlmacen_Items.jasper"
I hope it is useful.