Java iTextPDF和XMLWorker-应用引擎在字体加载期间将MappedByteBuffer类列入黑名单

Java iTextPDF和XMLWorker-应用引擎在字体加载期间将MappedByteBuffer类列入黑名单,java,google-app-engine,fonts,itext,xmlworker,Java,Google App Engine,Fonts,Itext,Xmlworker,我有一个AppEngineJavaMaven项目,配置了以下依赖项 <dependency> <groupId>com.itextpdf.tool</groupId> <artifactId>xmlworker</artifactId> <version>5.5.9</version> <exclusions> <exclusion>

我有一个AppEngineJavaMaven项目,配置了以下依赖项

<dependency>
    <groupId>com.itextpdf.tool</groupId>
    <artifactId>xmlworker</artifactId>
    <version>5.5.9</version>
    <exclusions>
        <exclusion>
            <artifactId>itextpdf</artifactId>
            <groupId>com.itextpdf</groupId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextg</artifactId>
    <version>5.5.9</version>
</dependency>
在localhost环境中没有问题,PDF是正确生成的。在联机环境中,我得到了这个错误

java.lang.NoClassDefFoundError: java.nio.MappedByteBuffer is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.apphosting.runtime.security.shared.stub.java.nio.channels.FileChannel_.map(FileChannel.java)
at com.itextpdf.text.io.MappedChannelRandomAccessSource.open(MappedChannelRandomAccessSource.java:105)
at com.itextpdf.text.io.FileChannelRandomAccessSource.<init>(FileChannelRandomAccessSource.java:74)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:240)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:224)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:191)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.<init>(RandomAccessFileOrArray.java:151)
at com.itextpdf.text.pdf.TrueTypeFont.process(TrueTypeFont.java:800)
at com.itextpdf.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:499)
at com.itextpdf.text.pdf.BaseFont.getAllFontNames(BaseFont.java:1233)
at com.itextpdf.text.FontFactoryImp.register(FontFactoryImp.java:452)
at com.itextpdf.text.FontFactoryImp.register(FontFactoryImp.java:439)
java.lang.NoClassDefFoundError:java.nio.MappedByteBuffer是一个受限类。有关更多详细信息,请参阅谷歌应用程序引擎开发者指南。
在com.google.apphosting.runtime.security.shared.stub.java.nio.channels.FileChannel.map(FileChannel.java)上
位于com.itextpdf.text.io.MappedChannelRandomAccessSource.open(MappedChannelRandomAccessSource.java:105)
位于com.itextpdf.text.io.FileChannelRandomAccessSource。(FileChannelRandomAccessSource.java:74)
位于com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:240)
位于com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:224)
位于com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:191)
请访问com.itextpdf.text.pdf.randomAccessFileOrray。(randomAccessFileOrray.java:151)
在com.itextpdf.text.pdf.TrueTypeFont.process上(TrueTypeFont.java:800)
请访问com.itextpdf.text.pdf.TrueTypeFont。(TrueTypeFont.java:499)
请访问com.itextpdf.text.pdf.BaseFont.getAllFontNames(BaseFont.java:1233)
在com.itextpdf.text.FontFactoryImp.register上(FontFactoryImp.java:452)
在com.itextpdf.text.FontFactoryImp.register上(FontFactoryImp.java:439)
从我已经完成的搜索中,我发现了两个重要的注意事项:

  • 为了避免这种问题,我需要直接从字体字节创建

  • 黑名单类(java.nio.MappedByteBuffer)无法在库的G版本中删除,因为它是

这里的问题是我无法在
XMLWorkerFontProvider
中注册
Font
对象,似乎Font对象可以直接用于iText的主API,但不能用于XMLWorker工具


这类问题有什么解决办法吗?是否真的不可能在应用程序引擎中运行的html工作中使用自定义字体?

另一方面,从
5.5.9
开始,我们将XMLWorker对iText的依赖性设置为可选,这意味着您不再需要排除策略(如果我正确理解Maven依赖性的话).并回答您的问题:感谢您报告此问题。你链接到的论坛帖子包含过时的信息。自3年以来,已经有一个独立的iTextG分支(您已经在使用它)。这是我们的意图,iText应该在应用程序引擎上工作。我请我们的一位开发人员研究这个问题。我们会随时通知你的。
java.lang.NoClassDefFoundError: java.nio.MappedByteBuffer is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.apphosting.runtime.security.shared.stub.java.nio.channels.FileChannel_.map(FileChannel.java)
at com.itextpdf.text.io.MappedChannelRandomAccessSource.open(MappedChannelRandomAccessSource.java:105)
at com.itextpdf.text.io.FileChannelRandomAccessSource.<init>(FileChannelRandomAccessSource.java:74)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:240)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:224)
at com.itextpdf.text.io.RandomAccessSourceFactory.createBestSource(RandomAccessSourceFactory.java:191)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.<init>(RandomAccessFileOrArray.java:151)
at com.itextpdf.text.pdf.TrueTypeFont.process(TrueTypeFont.java:800)
at com.itextpdf.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:499)
at com.itextpdf.text.pdf.BaseFont.getAllFontNames(BaseFont.java:1233)
at com.itextpdf.text.FontFactoryImp.register(FontFactoryImp.java:452)
at com.itextpdf.text.FontFactoryImp.register(FontFactoryImp.java:439)