我有一个CodenameOne项目,大部分已完成,我需要将桌面版本与PDFBox集成。我正在尝试打开文档并将页面呈现给我在应用程序中显示的图像。
我收到以下错误:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.pdfbox.pdmodel.font.PDTrueTypeFont
at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:100)
at org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:213)
at org.apache.pdfbox.util.PDFStreamEngine.getFonts(PDFStreamEngine.java:607)
at org.apache.pdfbox.util.operator.SetTextFont.process(SetTextFont.java:59)
at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:139)
at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
at co.za.gingetsuryuu.pdfreader.PDFInterfaceImpl$1.run(PDFInterfaceImpl.java:69)
at java.lang.Thread.run(Thread.java:745)
java.lang.NoClassDefFoundError: Could not initialize class org.apache.pdfbox.pdmodel.font.PDTrueTypeFont
at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:100)
at org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:213)
at org.apache.pdfbox.util.PDFStreamEngine.getFonts(PDFStreamEngine.java:607)
at org.apache.pdfbox.util.operator.SetTextFont.process(SetTextFont.java:59)
at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:139)
at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
at co.za.gingetsuryuu.pdfreader.PDFInterfaceImpl$1.run(PDFInterfaceImpl.java:69)
at java.lang.Thread.run(Thread.java:745)
java.lang.NoClassDefFoundError: Could not initialize class org.apache.pdfbox.pdmodel.font.PDTrueTypeFont
at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:100)
at org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:213)
at org.apache.pdfbox.util.PDFStreamEngine.getFonts(PDFStreamEngine.java:607)
at org.apache.pdfbox.util.operator.SetTextFont.process(SetTextFont.java:59)
at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:139)
at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
at co.za.gingetsuryuu.pdfreader.PDFInterfaceImpl$1.run(PDFInterfaceImpl.java:69)
at java.lang.Thread.run(Thread.java:745)
我完全失去了。我已经检查了包含的库,它设法渲染一个或两个页面,但不多于此。我甚至检查过这个功能确实存在,而且确实存在。
答案 0 :(得分:1)
问题似乎与Codename One执行构建过程的方式有关。通过将jar文件包含在结果项目中并使它们在jar加载顺序中比app.jar文件加载更高,问题就解决了。
答案 1 :(得分:0)
您是否将PDF框API的jar放在native / javase文件夹下?如果不是,罐子将不会被发送到构建服务器,并且不会被打包作为应用程序的一部分。