on 07-29-2010 6:30 AM
Hi,
I have a project requirment in which i need to count the attachments of a mail initially and then based on that i need to proceed with further processing.It is a SAP XI 7.0 env.hence i was adviced go for an adapter module.After deploying the module it is not picking my message rather it throws an error
"exception caught during processing mail message[1]; com.sap.aii.af.mp.module.ModuleException caused by: java.lang.NullPointerException u201D
code is as below
PFB the code below
/*
Created on Jul 28, 2010
*
To change the template for this generated file go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
package countAttachment;
/**
@author Shafeek_Siraj
*
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import com.sap.aii.af.mp.module.*;
import com.sap.aii.af.service.auditlog.*;
import com.sap.aii.af.ra.ms.api.*;
/**
@ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>
@ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>
@ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>
@ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>
@stateless
*/
public class CheckAttachment implements SessionBean, Module{
private SessionContext myContext;
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext context) {
myContext = context;
}
public void ejbCreate() throws CreateException {
}
public ModuleData process(ModuleContext moduleContext,
ModuleData inputModuleData)
throws ModuleException {
String sMessage = "";
Object obj = null;
Message msg = null;
try {
// get the message from the mail
obj = inputModuleData.getPrincipalData();
msg = (Message)obj;
AuditMessageKey amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"CheckAttachment: Module called");
// count attachments
int iCount = msg.countAttachments();
if(iCount==0)
{
sMessage="No attachments";
Audit.addAuditLogEntry(amk,AuditLogStatus.WARNING," Status : " + sMessage);
}
else if(iCount>1)
{
sMessage="More than 1 attachments found";
Audit.addAuditLogEntry(amk,AuditLogStatus.WARNING," Status : " + sMessage);
}
else
{
sMessage="Success";
Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS," Status : " + sMessage);
}
String sSubject=msg.getMessageProperty("http://sap.com/xi/XI/System/Mail","sHeaderSUBJECT");
msg.setMessageProperty("http://sap.com/xi/XI/System/Mail","sHeaderSUBJECT",sSubject.concat(";"+sMessage));
inputModuleData.setPrincipalData(msg);
}
catch (Exception e) {
// raise exception, when an error occurred
ModuleException me = new ModuleException(e);
throw me;
}
// return XI message
return inputModuleData;
}
}
Kindly suggest some solution resolve this.
Thanks,
Shafeek
Hi Shafeek,
your post is difficult to read but issues like this are often caused by the module being in the wrong order in the module sequence table. i.e., the MailAdapterBean should be the last module in the table.
Regards
Kenny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.