Tenho um aplicativo usando Apache FOP para criar um PDF que inclui uma imagem SVG (é um logotipo e é sempre o mesmo). Acho que ele não inclui a imagem se eu usar o plugin assembly do Maven para criar um jar-with-dependencies. Fiz um trabalho para restringi-lo e parece que o carregador de imagem SVG não é registrado quando o aplicativo está em um jar - então não é a parte PDF do FOP como tal, é o ImageManager que está em xmlgraphics-commons.
Colei um exemplo mínimo abaixo. Serão necessários arquivos chamados img.png
e img.tiff
no img.svg
diretório atual.
Se você executar isso, mvn exec:java
ele imprime
image (image/png)
image (image/tiff)
image (image/svg+xml)
e se você correr mvn package
e então java -cp .\target\mavenproject2-1.0-SNAPSHOT-jar-with-dependencies.jar project.Mavenproject2
você conseguir
image (image/png)
image (image/tiff)
Nov 26, 2024 10:19:15 AM project.Mavenproject2 load
SEVERE: Loading img.svg
org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for image
at org.apache.xmlgraphics.image.loader.ImageManager.preloadImage(ImageManager.java:181)
at project.Mavenproject2.load(Mavenproject2.java:43)
at project.Mavenproject2.main(Mavenproject2.java:31)
null
Portanto, o carregador SVG não está disponível.
Existe uma maneira de dizer ao FOP para registrar esse carregador SVG ou é impossível executá-lo a partir de um jar com dependências e eu deveria tentar empacotar o aplicativo de outra forma?
Código de exemplo mínimo:
package project;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import org.apache.fop.apps.FopFactoryBuilder;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSource;
public class Mavenproject2 {
public static void main(String[] args) throws FileNotFoundException, ImageException, IOException {
Mavenproject2 me = new Mavenproject2();
System.out.println(me.load("img.png"));
System.out.println(me.load("img.tiff"));
System.out.println(me.load("img.svg"));
}
public Mavenproject2() {
URI base = URI.create("https://example.com/nowhere");
FopFactoryBuilder ffb = new FopFactoryBuilder(base);
this.imageManager = ffb.getImageManager();
}
private final ImageManager imageManager;
public ImageInfo load(String ff) {
try {
File sourceFile = new File(ff);
ImageInputStream iis = ImageIO.createImageInputStream(sourceFile);
ImageInfo preloadImage = imageManager.preloadImage("image", new ImageSource(iis, "image", true));
return preloadImage;
} catch (IOException | ImageException ex) {
Logger.getLogger(Mavenproject2.class.getName()).log(Level.SEVERE, "Loading " + ff, ex);
}
return null;
}
}
e o POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project</groupId>
<artifactId>mavenproject2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.10</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<exec.mainClass>project.Mavenproject2</exec.mainClass>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
jar-with-dependencies
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Usando o maven 3.9.9 no Windows 11.
[editar] Registro conforme solicitado por @francesco-poli Quando não estiver em um jar (e funciona)
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderGIF with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderBMP with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderEMF with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderEPS with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO with priority 2000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderRawPNG with priority 2000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.fop.image.loader.batik.PreloaderWMF with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.fop.image.loader.batik.PreloaderSVG with priority 1000
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/png, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/png, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/vnd.wap.wbmp, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/vnd.wap.wbmp, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/x-png, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/x-png, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/jpeg, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/jpeg, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/tiff, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/tiff, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/bmp, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/bmp, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/gif, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/gif, Flavor = BufferedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/png, Flavor = image/png;Raw
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/jpeg, Flavor = image/jpeg;Raw
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/tiff, Flavor = image/tiff;Raw
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/x-emf, Flavor = image/x-emf;Raw
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRawCCITTFax: MIME = image/tiff, Flavor = RawCCITTFax
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryEPS: MIME = application/postscript, Flavor = application/postscript;Raw
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryInternalTIFF: MIME = image/tiff, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryPNG: MIME = image/png, Flavor = RenderedImage
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.fop.image.loader.batik.ImageLoaderFactorySVG: MIME = image/svg+xml, Flavor = text/xml;DOM;namespace=http://www.w3.org/2000/svg
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.fop.image.loader.batik.ImageLoaderFactoryWMF: MIME = image/x-wmf, Flavor = WMFRecordStore
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterBuffered2Rendered
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterG2D2Bitmap
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterBitmap2G2D
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterRendered2PNG
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.fop.image.loader.batik.ImageConverterSVG2G2D
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.fop.image.loader.batik.ImageConverterG2D2SVG
Nov 26, 2024 12:34:44 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.fop.image.loader.batik.ImageConverterWMF2G2D
Quando em uma jarra (e não funciona)
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF with priority 1000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderGIF with priority 1000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG with priority 1000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderBMP with priority 1000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderEMF with priority 1000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderEPS with priority 1000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO with priority 2000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerPreloader
FINE: Registered org.apache.xmlgraphics.image.loader.impl.PreloaderRawPNG with priority 2000
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/png, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/png, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/vnd.wap.wbmp, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/vnd.wap.wbmp, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/x-png, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/x-png, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/jpeg, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/jpeg, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/tiff, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/tiff, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/bmp, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/bmp, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/gif, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO: MIME = image/gif, Flavor = BufferedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/png, Flavor = image/png;Raw
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/jpeg, Flavor = image/jpeg;Raw
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/tiff, Flavor = image/tiff;Raw
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw: MIME = image/x-emf, Flavor = image/x-emf;Raw
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRawCCITTFax: MIME = image/tiff, Flavor = RawCCITTFax
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryEPS: MIME = application/postscript, Flavor = application/postscript;Raw
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryInternalTIFF: MIME = image/tiff, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerLoaderFactory
FINE: Registered org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryPNG: MIME = image/png, Flavor = RenderedImage
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterBuffered2Rendered
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterG2D2Bitmap
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterBitmap2G2D
Nov 26, 2024 12:37:49 PM org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry registerConverter
FINE: Registered: org.apache.xmlgraphics.image.loader.impl.ImageConverterRendered2PNG
[editar2]
Pode estar no caminho certo. Os pré-carregadores de imagem são identificados usando org.apache.xmlgraphics.util.Service
a classe xmlgraphics que varre os arquivos no diretório META-INF.services dentro do jar. Em fop-core.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader está:
org.apache.fop.image.loader.batik.PreloaderWMF
org.apache.fop.image.loader.batik.PreloaderSVG
e em xmlgraphics-commons-2.10.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader é
org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF
org.apache.xmlgraphics.image.loader.impl.PreloaderGIF
org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG
org.apache.xmlgraphics.image.loader.impl.PreloaderBMP
org.apache.xmlgraphics.image.loader.impl.PreloaderEMF
org.apache.xmlgraphics.image.loader.impl.PreloaderEPS
org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO
org.apache.xmlgraphics.image.loader.impl.PreloaderRawPNG
Então, se eu misturar os vários jars com o plugin assembly, apenas um dos arquivos de serviço relevantes sobreviverá - neste caso, parece o último.
Esse problema se deve ao fato de que existem duas bibliotecas (
fop-core-2.10.jar
exmlgraphics-common-2.10.jar
) que contêm os mesmos arquivos spi nosMETA-INF/services
arquivos, precisamente:org.apache.xmlgraphics.image.loader.spi.ImageConverter
org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory
org.apache.xmlgraphics.image.loader.spi.ImagePreloader
Usando os
maven-assembly-plugin
leads para ter apenas a cópia de uma das duas bibliotecas a ser gravada no jar final.Sugiro que você substitua o assembly pelo
maven-shade-plugin
que pode mesclar/anexar o conteúdo dos arquivos correspondentes, assim:Dê uma olhada também na página de documentação ( https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer ) e também nesta outra pergunta ( maven Assembly plugin is not appending/merging META-INF/services/spi.AutoDiscoverable ).