on 03-12-2010 8:37 PM
Boa tarde grupo, fiz um adapter module mas quando fui utiliza-lo no meu adapter de e-mail o mesmo me retorna o erro
MP: Exception caught with cause java.lang.NullPointerException.
Preciso de ajuda pois coloquei Audit messages para Debug e para acompanhar em que passos do codigo estava passando, mas ele dá o erro acima e não retorna nenhuma das mensagens de log.
Segue o codigo que implementei posso estar fazendo algo errado.
/*
* Created on 05/03/2010
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package samples;
import java.rmi.RemoteException;
import java.util.Iterator;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.mp.module.ModuleException;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.MessageDirection;
import com.sap.aii.af.ra.ms.api.Payload;
import com.sap.aii.af.service.auditlog.Audit;
import com.sap.aii.af.service.auditlog.AuditDirection;
import com.sap.aii.af.service.auditlog.AuditLogStatus;
import com.sap.aii.af.service.auditlog.AuditMessageKey;
/**
* @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 CondenseAttachment implements SessionBean, Module {
public void ejbCreate(){
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbActivate()
*/
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbRemove()
*/
public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
*/
public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.sap.aii.af.mp.module.Module#process(com.sap.aii.af.mp.module.ModuleContext, com.sap.aii.af.mp.module.ModuleData)
*/
public ModuleData process( ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException {
try {
//Declaração de Variaveis
String content = "";
Object obj = null;
Message msg = null;
AuditMessageKey amk = null;
//OutputMessage é uma classe gerada
OutputMessage parseobj = new OutputMessage();
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
if (msg.getMessageDirection().equals(MessageDirection.OUTBOUND))
amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.OUTBOUND);
else
amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.INBOUND);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Entrou com sucesso no ModuleBean: ");
}
catch (Exception e) {
ModuleException me = new ModuleException(e);
throw me;
}
//Le os attachments para ler o conteudo
try {
Iterator itr = msg.getAttachmentIterator();
Audit.addAuditLogEntry( amk,AuditLogStatus.SUCCESS,"Lendo anexos do Email");
Payload payload = null;
while (itr.hasNext()) {
payload = (Payload) itr.next();
String contentType = payload.getContentType();
// Content Type traz algo como: text/plain;charset="UTF-8";name="file.txt"
contentType = contentType.replaceAll(""","");
int i = contentType.lastIndexOf(".") + 1;
String extName = contentType.substring(i);
//Checa se o arquivo lido é um xml
if (extName.equalsIgnoreCase("xml")) {
//Checa o nome do attachment e exclui o MainDocument
if (!payload.getName().equalsIgnoreCase("MainDocument")) {
Audit.addAuditLogEntry( amk,AuditLogStatus.SUCCESS,"Nome do anexo: " + payload.getName());
//calls the method to parse attachment content.
content = content + parseobj.parseMessage(payload.getInputStream());
}
}
}
content = content + "</MessageSplit>";
//Creates a Text payload to set the email content.
Message msgPrinc = (Message) inputModuleData.getPrincipalData();
Payload payloadPric = msg.getDocument();
payloadPric.setContent(content.getBytes("UTF-8"));
inputModuleData.setPrincipalData(msgPrinc);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Module encerrado com sucesso");
} catch (Exception e) {
ModuleException me = new ModuleException(e);
}
return inputModuleData;
}
}
Agradeço a ajuda.
O problema estava na versão do meu JDK obrigado
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.