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

为君一笑 提交于 2020-07-23 07:11:27

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/61889015/exception-referring-start-non-translatable-while-working-with-java-itext-and-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!