英文:
Exception referring # START NON-TRANSLATABLE while working with java itext and IBM i RPG ILE
问题
使用Java iText库进行工作,进行了一个非常简单的测试。代码执行通过,但在关闭文档时出现了java.lang.String.compareToIgnoreCase的空指针异常。
这是在将iText Java代码嵌入IBM i RPGIV代码时发生的情况。目前还不确定这是否是JNI/RPGIV转换问题(utf8应该转换为EBCDIC本机字符集),还是一个真正的iText问题。如果有任何iText开发人员可以确认是否可能是典型的iText问题,或者不像那样,尤其是对"START NON-TRANSLATABLE"的引用,这将有所帮助。
以下是一些相关的异常信息:
异常线程:"main"
开始
非可翻译
java.lang.NullPointerException
在java.lang.String.compareToIgnoreCase(String.java:603)处
在java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:94)处
在java.io.BufferedOutputStream.flush(BufferedOutputStream.java:152)处
在com.itextpdf.text.pdf.OutputStreamCounter.flush(OutputStreamCounter.java:89)处
在com.itextpdf.text.DocWriter.close(DocWriter.java:233)处
在com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1341)处
在com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:901)处
在com.itextpdf.text.Document.close(Document.java:415)处
这是我的Plex Action图表代码:
Element接口(Paragraph实现了Element):
这些是我的Plex API实现:
创建文档:
创建PdfWriter:
打开文档:
创建段落:
将段落添加到文档:
关闭文档:
最后,我使用以下值启动Java:
classpath = 库的完整列表(包括iText + Apache POI,全部运行)
java_home = Java 7的路径
英文:
working with java itext library, with a very simple test. Code passes but when closing document, it fails due to null pointer exception with java.lang.String.compareToIgnoreCase.
It happens while embedding itext java code into IBM i RPGIV code. Not sure yet if it is a JNI/RPGIV conversion problem (utf8 should be converted to EBCDIC native charset) or a proper itext issue. It would help if any itext developer could confirm me if it could be a typical itext issue or not sounds like that, specially the reference to START NON-TRANSLATABLE.
> Exception in thread "main"# START
> NON-TRANSLATABLEjava.lang.NullPointerException at
> java.lang.String.compareToIgnoreCase(String.java:603)
> at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:94)
> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:152)
> at
> com.itextpdf.text.pdf.OutputStreamCounter.flush(OutputStreamCounter.java:89)
> at com.itextpdf.text.DocWriter.close(DocWriter.java:233)
> at com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1341)
> at com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:901)
> at com.itextpdf.text.Document.close(Document.java:415)
This is my Plex Action diagram code:
PdfWriter RPG prototype:
Method Document.open:
Class Element Paragraph:
Paragraph constructor RPG Prototype
Element interface (Paragraph implements Element):
Add paragraph to document method:
Document close method:
These are my Plex API implemented:
Create document:
create PdfWriter:
Open document:
create paragraph:
add paragraph to document
Close document:
Finally, I start java with these values:
classpath = full list of libraries (itext + Apache POI, all running)
java_home = path to java 7
答案1
得分: 0
最终解决了,在IBM i上使用纯Java测试itext。今天它正常工作,并为我提供了找到嵌入式itext问题所在的方向。问题出在错误使用了PdfWriter类。我将EBCDIC字符串转换为jstring,然后分配了一个FileOutputStream对象而没有进行转换。从jstring获取FileOutputStream对象将正确的文件对象传递给了PdfWriter。现在过程如下所示:
/free
PhraseString = new_String( %trim(&(1:)));
pdfFilePath = new_FileOutputStream(PhraseString);
pdfWriter = get_PdfWriter( pdfDocument: pdfFilePath);
/end-free
英文:
Finally solved, after testing itext on IBM i in plain java. It worked today, and give me directions to locate the embedded itext issue. It was the PdfWriter class which was improperly used. I converted a EBCDIC string to jstring, and then assigned a FileOutputStream object without conversion. Getting a FileOutputStream object from jstring passed the right file object to PdfWriter. The procedure looks now as follows:
/free
PhraseString = new_String( %trim(&(1:)));
pdfFilePath = new_FileOutputStream(PhraseString);
pdfWriter = get_PdfWriter( pdfDocument: pdfFilePath);
/end-free
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论