I'm trying to feed a simple .gif image from my GXT application to jasper so it generates an Excel report.
The problem I'm having is that after trying a multitude of options, I always get the "java.lang.NullPointerException" on the server-side of things.
I have the following code in my Jasper report:
<parameter name="logo" class="java.lang.String"/>
...
<image>
<reportElement uuid="2f9765a4-f1dc-4af4-9ddf-fae1c7a3d152" x="110" y="0" width="206" height="40"/>
<imageExpression><![CDATA[$P{logo}]]></imageExpression>
</image>
And the Java code:
FileResolver fileResolver = new FileResolver() {
@Override
public File resolveFile(String fileName) {
URI uri;
try {
uri = new URI(this.getClass().getResource(fileName).getPath());
return new File(uri.getPath());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
};
parameters.put("logo", fileResolver.resolveFile("logo.GIF"));
I've tried several solutions out there and had problems with all of them.
The logo.gif is placed in the .war folder of the compiled GWT application, the contents of which are archived as a .war and deployed on a Tomcat 7.0 server.
Hopefully someone with a bit more experience will help me out and let me know what I'm doing wrong.