|
I had so much fun working through Scott's POI examples, I decided to step out and try to send email using the JavaMail API on my own.
Here's the problem, I have everything compiling correctly, but one of the 'enumerated' attributes of an address RecipientType is not an enumeration but an inside class with static final objects defined inside the Message Class like this:
package javax.mail;
... some stuff
public abstract class Message implements Part {
.. a lot of stuff
public static class RecipientType implements Serializable {
/**
* The "To" (primary) recipients.
*/
public static final RecipientType TO = new RecipientType("To");
/**
* The "Cc" (carbon copy) recipients.
*/
public static final RecipientType CC = new RecipientType("Cc");
/**
* The "Bcc" (blind carbon copy) recipients.
*/
public static final RecipientType BCC = new RecipientType("Bcc");
/**
* The type of recipient, usually the name of a corresponding
* Internet standard header.
*
* @serial
*/
protected String type;
private static final long serialVersionUID = -7479791750606340008L;
/**
* Constructor for use by subclasses.
*
* @param type the recipient type
*/
protected RecipientType(String type) {
this.type = type;
}
... a lot more stuff
I have it defined in RPG like this:
dcl-c RECIPIENTTYPE_CLASS 'javax.mail.Message.RecipientType';
dcl-c RECIPIENTTYPE_TO 'javax.mail.Message.RecipientType.TO';
dcl-c RECIPIENTTYPE_CC 'javax.mail.Message.RecipientType.CC';
dcl-c RECIPIENTTYPE_BCC 'javax.mail.Message.RecipientType.BCC';
dcl-s RecipientType Object(*JAVA
: RECIPIENTTYPE_CLASS);
dcl-s RecipientTypeTo Object(*JAVA
: RECIPIENTTYPE_TO);
dcl-s RecipientTypeCc Object(*JAVA
: RECIPIENTTYPE_CC);
dcl-s RecipientTypeBcc Object(*JAVA
: RECIPIENTTYPE_BCC);
// ----------------------------------------------------------------
// message_addRecipient(Message.RecipientType, InternetAddress)
// Adds a recipient to a mime message
//
// type - (input) Message.RecipientType object
// address - (input) InternetAddress object
// ----------------------------------------------------------------
dcl-pr message_addRecipient
ExtProc(*JAVA
: MIMEMESSAGE_CLASS
: 'addRecipient');
type Like(RecipientType) const;
address Like(Address) const;
end-pr;
Here is the call that is failing:
message_addRecipient(message: RecipientTypeTo: addr);
I am getting a method not found message, here is the signature it is looking for:
Additional Message Information
Message ID . . . . . . : RNX0301 Severity . . . . . . . : 50
Message type . . . . . : Escape
Date sent . . . . . . : 07/01/15 Time sent . . . . . . : 15:39:06
Message . . . . : Java exception received when calling Java method.
Cause . . . . . : RPG procedure JMAILTST in program JVTLIB/JMAILTST received
Java exception "java.lang.NoSuchMethodError:
javax/mail/internet/MimeMessage.addRecipient(Ljavax/mail/Message/Recipi"
when calling method "addRecipient" with signature
"(Ljavax.mail.Message.RecipientType;Ljavax.mail.Address;)V" in class
"javax.mail.internet.MimeMessage".
Recovery . . . : Contact the person responsible for program maintenance to
determine the cause of the problem.
Technical description . . . . . . . . : If the exception indicates that the
Java class was not found, ensure the class for the method is in the class
path. If the exception indicates that the Java method was not found, check
the method name and signature. If the signature is not correct, change the
RPG prototype for the method, or change the Java method, so that the return
type and parameter types match. You can determine the signatures for all the
methods in class XYZ using command QSH CMD('javap -s XYZ').
Here is the signature in the jar (from javap -s):
public void addRecipient(javax.mail.Message$RecipientType, javax.mail.Address) throws javax.mail.MessagingException;
Signature: (Ljavax/mail/Message$RecipientType;Ljavax/mail/Address;)V
It obviously knows the difference between an inside class and a regular class. See the $ instead of a . between Message and RecipientType in the javap output. So how do I define this to RPG so that I can use those inner class objects?
Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx
--
This is the RPG programming on the IBM i (AS/400 and 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-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.