|
Hi Scott,
Now all work fine , thanks a lot for your support
Basilio
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Scott Klement
Sent: venerdANOT 9 febbraio 2007 20.26
To: RPG programming on the AS400 / iSeries
Subject: Re: itext prototype
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.html
Although 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-free
>
> The error I get is: Message . . . . : Java exception received when
calling Java method.
> Cause . . . . . : ....Java exception "java.lang.NoSuchMethodError:
add" when calling
> method "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?
>
> Thanks
>
>
>
> Basilio
>
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.