简体   繁体   中英

Exception referring # START NON-TRANSLATABLE while working with java itext and IBM i RPG ILE

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:

在此处输入图像描述

Document RPG prototype: 在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM