1

我有一个 Spring Boot 应用程序,它基本上从客户端接收 JSON 并创建/返回 PDF。

我可以毫无问题地加载JPG图像。但是当我加载PNG文件时,我遇到了这个异常。我的 Spring Boot“战争”应用程序在 Tomcat 中运行。

如果我通过“java -jar ...”执行 Spring Boot 应用程序,它运行良好。

  • Apache Tomcat/9.0.29
  • 无头 OpenJDK 64 位 VM 1.8
  • 春季启动 2.2.1
  • 打开PDF 1.3
  • CentOS Linux 7
2020-02-24 01:57:14,042 ERROR [http-nio-8080-exec-217] org.springframework.boot.web.servlet.support.ErrorPageFilter: Forwarding to error page from request [/pdf/create] due to exception [Could not initialize class java.awt.image.DataBuffer]
java.lang.NoClassDefFoundError: Could not initialize class java.awt.image.DataBuffer
    at javax.imageio.ImageTypeSpecifier.createComponentCM(ImageTypeSpecifier.java:249)
    at javax.imageio.ImageTypeSpecifier$Interleaved.<init>(ImageTypeSpecifier.java:305)
    at javax.imageio.ImageTypeSpecifier.createInterleaved(ImageTypeSpecifier.java:399)
    at javax.imageio.ImageTypeSpecifier.createSpecifier(ImageTypeSpecifier.java:1169)
    at javax.imageio.ImageTypeSpecifier.getSpecifier(ImageTypeSpecifier.java:1118)
    at javax.imageio.ImageTypeSpecifier.createFromBufferedImageType(ImageTypeSpecifier.java:901)
    at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(PNGImageReader.java:1531)
    at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1318)
    at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1614)
    at javax.imageio.ImageIO.read(ImageIO.java:1462)
    at javax.imageio.ImageIO.read(ImageIO.java:1357)
    at com.lowagie.text.ImageLoader.getPngImage(ImageLoader.java:76)
    at com.lowagie.text.Image.getInstance(Image.java:284)
    at com.company.myapp.service.pdf.pages.Page00.render(Page00.java:69)
    at com.company.myapp.service.pdf.pages.PageImpl.<init>(PageImpl.java:27)
    at com.company.myapp.service.pdf.pages.Page00.<init>(Page00.java:21)
    at com.company.myapp.service.PdfServiceImpl.getPDF(PdfServiceImpl.java:33)
    at com.company.myapp.controller.PdfController.generate(PdfController.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
4

0 回答 0