java.lang.UnsatisfiedLinkError:“.../javajpeg.dll”:无法在 Windows Server 上找到依赖库

问题描述 投票:0回答:1

我编写了一个服务,该服务使用与 Apache Tomcat procrun 一起运行的 Apache PDFBox 执行打印。给出了 jre,其中包含 javajpeg.dll。它在我的 Windows 11 客户端计算机上运行没有任何问题。

在服务器上运行,遇到以下错误:

java.lang.UnsatisfiedLinkError: ".../javajpeg.dll": Can´t find dependent libraries

当服务尝试加载 JPEGImageLoader 时,会发生此错误。

以下是有关服务器和环境的一些详细信息:

服务器操作系统:Microsoft Windows Server 2016 Datacenter

Java版本:

java.exe -version
openjdk version "11.0.5" 2019-10-15 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.5+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)

堆栈跟踪:

java.lang.UnsatisfiedLinkError: ...\javajpeg.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load0(Native Method) ~[?:?]
    at java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430) ~[?:?]
    at java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487) ~[?:?]
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684) ~[?:?]
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2638) ~[?:?]
    at java.lang.Runtime.loadLibrary0(Runtime.java:829) ~[?:?]
    at java.lang.System.loadLibrary(System.java:1870) ~[?:?]
    at com.sun.imageio.plugins.jpeg.JPEGImageReader$1.run(JPEGImageReader.java:92) ~[?:?]
    at com.sun.imageio.plugins.jpeg.JPEGImageReader$1.run(JPEGImageReader.java:90) ~[?:?]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.<clinit>(JPEGImageReader.java:89) ~[?:?]
    at com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(JPEGImageReaderSpi.java:85) ~[?:?]
    at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:320) ~[?:?]
    at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:532) ~[?:?]
    at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:516) ~[?:?]
    at org.apache.pdfbox.filter.Filter.findImageReader(Filter.java:155) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.filter.DCTFilter.decode(DCTFilter.java:58) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:80) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:175) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.pdmodel.common.PDStream.createInputStream(PDStream.java:243) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.createInputStream(PDImageXObject.java:791) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:517) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:226) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:481) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:462) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1110) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:67) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:933) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:514) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:492) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:277) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.rendering.PDFRenderer.renderPageToGraphics(PDFRenderer.java:458) ~[pdfbox-2.0.24.jar:2.0.24]
    at org.apache.pdfbox.printing.PDFPrintable.print(PDFPrintable.java:264) ~[pdfbox-2.0.24.jar:2.0.24]
    at sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:2275) ~[?:?]
    at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1654) ~[?:?]

我希望它加载 javajpeg.dll。 听起来好像并不是所有依赖项都能找到。 在服务器上加载类/依赖项有区别吗?

java tomcat pdfbox java-11
1个回答
0
投票

我和你有同样的观点“对服务器的依赖”。当我遇到这些问题时,我会提出一些建议。

  1. 确保您拥有与您的 Java 版本和操作系统兼容的正确版本的“javajpeg.dll”文件。

  2. 设置Java库路径以包含“javajpeg.dll”文件所在的目录。这可以通过将以下命令行参数添加到 Java 命令来完成: -Djava.library.path=/path/to/dll/directory 将“/path/to/dll/directory”替换为包含以下内容的目录的实际路径“javajpeg.dll”文件。

    java -Djava.library.path=/path/to/dll/directory -jar YourService.jar

有一个例子。

不知道这些方法是否有效。如果您还有其他方法来解决挑战,请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.