Reputation: 971
I have problems with my Apache FOP application.
Everything worked fine, until I started to pack external files (xsl, ttf, ...) from an external working directory into the jar file of the application. Since then, no images are loaded anymore and I get the following error:
FOUserAgent - Image not available. URI: data:image/jpeg;base64,....
Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is
not supported. No ImagePreloader found for data:image/jpeg;base64,...(No context info available)
org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for data:image/jpeg;base64
In the xsl file, the images are embedded with:
<fo:external-graphic xsl:use-attribute-sets="helpicon"
fox:alt-text="helpicon"
src="url('data:image/jpg;base64,...I'm the base64 encoded image data...')">
</fo:external-graphic>
Why are images not working anymore, when I pack the files into the jar? The images are embedded as a base64 string into the xsl file, so the image data must be available...
Thanks :)
Edit 1 I'm setting the FopFactory base url with:
String path = MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");
File jar = new File(decodedPath);
fopFactory.setBaseURL(jar.getParent());
and this is my ClasspathUriResolver:
public class ClasspathUriResolver implements URIResolver {
@Override
public Source resolve(String fileName, String base) throws TransformerException {
System.out.print(" RESOLVING: " + fileName);
URL url = getClass().getClassLoader().getResource(fileName);
StreamSource jarFileSS = new StreamSource();
System.out.println(" TO: " + url.toString());
try {
InputStream jarfileIS = url.openStream();
jarFileSS.setInputStream(jarfileIS);
} catch (IOException ioExp) {
throw new TransformerException(ioExp);
}
return jarFileSS;
}
I checked the log from the ClasspathUriResolver, included files (fonts, stylesheets) get resolved correctly.
Upvotes: 2
Views: 3309
Reputation: 971
I've updated jdk version to 1.7.71 and now everything worked. Thanks :)
Upvotes: 0