|
Hi Basilio,The error you posted is "java.lang.NoSuchMethodError": This error is not related to the classpath. If this had been a classpath error, it would've complained that it couldn't find a class definition -- but that's not the case here, here it says it can't find a method.
Java searches the class (which it has already found) to find the method. In order for it to find it, two different criteria have to match, the method name ("add" in this situation) and the method's signature('(Lcom.lowagie.text.Paragraph;)V" in this situation. Both have to match, or it will give you the NoSuchMethodError that you've posted to this mailing list.
Now, I'm not completely familiar with iText, so I ran a quick Google search for the Javadocs for the com.lowagie.text.Document class. I found them at the following link, but I have no idea if that's the same version that you're using:
http://www.docjar.com/docs/api/com/lowagie/text/Document.htmlAlthough those Javadocs do mention an "add" method, there's no add method that matches your signature. The signature is derived from the parameter types and return values. Your prototype is looking for a method that accepts an Paragraph object as a parameter, and returns nothing (void). However, the Javadocs reference an Add method that accepts any object that implements the Element interface, and returns a boolean value. So it makes perfect sense that you'd receive the error you're receiving.
Instead, try something like this:D ITXTElement S O CLASS(*JAVA D :'com.lowagie.text.Element')
D AddParagraphToDocument... D PR 1N ExtProc(*JAVA: D 'com.lowagie.text.Document': D 'add') D peParagraph like(ITXTElement)
When you call the method, you can still pass a Paragraph to it (as you were already doing) since Paragraph's implement the Element interface. So they're compatible with Elements. But the prototype must reference the Eleemnt, not the Paragraph, or the signature will be wrong.
Hope that helps. Basilio Merlino wrote:
I'm having trouble creating a prototype for the following java code:document.add(new Paragraph("Hello World") );Here's what I have so far: D jFileOutputStream... D S O CLASS(*JAVA D :'java.io.FileOutputStream') D Document S O CLASS(*JAVA D :'com.lowagie.text.Document')D ITXTParagraph S O CLASS(*JAVA D :'com.lowagie.text.Paragraph')D AddParagraphToDocument... D PR ExtProc(*JAVA: D 'com.lowagie.text.Document': D 'add') D peParagraph like(ITXTParagraph)D PdfDocument S LIKE(Document) D writerFile S LIKE(jFileOutputStream) D ThisWriter S LIKE(PdfWriter) D paragraph S LIKE(ITXTParagraph) /free// Document is created without errors (PdfDocument)// file output stream is created without errors (writerFile) // Paraghraph is created without errors (paragraph) AddParagraphToDocument(Document:Paragraph); /End-freeThe error I get is: Message . . . . : Java exception received when calling Java method. Cause . . . . . : ....Java exception "java.lang.NoSuchMethodError: add" when callingmethod "add" with signature "(Lcom.lowagie.text.Paragraph;)V" in class"com.lowagie.text.Document".I've checked everything and the spelling and capitalization is correct for the prototype. The jar file resides at /QIBM/UserData/Java400/ext, so this shouldn't be a classpath issue as far as I know. Can anyone tell me if they see anything wrong? ThanksBasilio
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.