0

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:

enter image description here

Document RPG prototype: enter image description here

PdfWriter RPG prototype: enter image description here Method Document.open: enter image description here Class Element Paragraph: enter image description here Paragraph constructor RPG Prototype enter image description here Element interface (Paragraph implements Element): enter image description here Add paragraph to document method: enter image description here Document close method: enter image description here

These are my Plex API implemented:

Create document:

enter image description here

create PdfWriter:

enter image description here

Open document:

enter image description here

create paragraph:

enter image description here

add paragraph to document

add paragraph to document

Close document:

enter image description here

Finally, I start java with these values: classpath = full list of libraries (itext + Apache POI, all running) java_home = path to java 7

Jorge Ubeda
  • 193
  • 5
  • 18
  • Please don't ask the same question multiple times, you asked the same thing yesterday... https://stackoverflow.com/questions/61867716/exception-on-closing-an-itext-pdf-by-using-rpg-ile-referring-to-start-non-tra – Charles May 19 '20 at 15:39
  • You are right, Charles. I was looking for help here and there, and wasn't aware I have asked same question yesterday here. I will delete the first one, because this second message have some additional history. Actually, I asked this current message focusing in itext developers, in order to discard (or not) an proper itext issue. – Jorge Ubeda May 19 '20 at 20:45
  • Done, Charles. Now, only one. Comparing both of them, there is no difference! – Jorge Ubeda May 19 '20 at 21:01
  • I see that my question gained two negative points. However, I don't see any explanation, nor anyone offering any help on the problem, or explanation of why my question is annoying / obvious / useless / inconductive. Meanwhile, my problem continues. Curious way to share knowledge. (not your case, Charles). – Jorge Ubeda May 20 '20 at 09:51
  • it really isn't a very good question, unless somebody happens to recognize the exact stack trace. Take a look at https://stackoverflow.com/help/how-to-ask and consider including at minimum the PR's you're using to call the java classes. At least part of the RPG code may also be useful. – Charles May 20 '20 at 17:22
  • @Charles: following your reccomendations, I edited content to add used prototypes and high level Plex code. RPG ILE code have limits in its use due to Plex limitations. Writting down my code I see that previously there is no reference to Plex use. Anyway, in this case, Plex almost does not interfers. – Jorge Ubeda May 21 '20 at 08:12
  • Reference to START NON-TRANSLATABLE seems to refer to RPG/EBCDIC conversions, but at least in my case, I cant find references to its work. – Jorge Ubeda May 21 '20 at 08:24
  • I have found now this case here in Stack Overflow: https://stackoverflow.com/questions/38109981/issue-exception-in-thread-main-start-non-translatablejava-lang-noclassdeffou It seems to help to focus: it is an IBM-side issue. It is probably a java configuration issue and perhaps a charset conversion issue. Better to find! – Jorge Ubeda May 21 '20 at 08:51
  • much better, though text snippets of source code are preferred rather than images...have you tried just straight RPG/java without Plex just to see if you get the same error? – Charles May 21 '20 at 19:53
  • Hi Charles. Regarding source code I was not able to format some parts as Stack Overflow dictates, After failing with editing rules several times, opted for images. Stack overflow rejected some code (columnar rules seems not recognized). Given I had little time, opted for images. – Jorge Ubeda May 21 '20 at 21:09
  • Regarding running a clean rpg without Plex, I will try this weekend, with time enough. However, I would say here there is no Plex code. I continue researching and found several referencies to IBM java configuration rules. I hope this weekend could investigate in this way. Found Websphere and Eclipse references. Not very documented but pointing to Globalization (locale) configuration rules. Maybe...It could be some as simple as a double quote in a properties file. – Jorge Ubeda May 21 '20 at 21:15
  • preparing this week a test of itext plain java code, I have received a couple of warnings like "Exception in thread "main"# START NON-TRANSLATABLE" related to NoClassDef exceptions, until have got a proper classpath for my test case. Indeed it is an IBM i JVM message, while building its environment. However, I can't yet figure out why it's created a null pointer exception for a java.lang.String operation. – Jorge Ubeda Jun 30 '20 at 09:43

1 Answers1

0

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
Jorge Ubeda
  • 193
  • 5
  • 18