cancel
Showing results for 
Search instead for 
Did you mean: 

retrieving the attachment in the adapter module

Former Member
0 Kudos

hi,

i have created an adapter module to retrieve the attachment payload. This module is placed after the Seeburger bic module chain. but everytime i execute the module i get null pointer exception.

i have used the following code to retrieve the attachment.

//code for retrieving the attachment

try {

Iterator itr = msg.getAttachmentIterator();

if (itr.hasNext()) {

while (itr.hasNext()) {

Payload attachment = (Payload) itr.next();

byte payLoadContent[] = null;

in_Data = attachment.getInputStream();

in_Data.read(payLoadContent);

attachmentContent = new String(payLoadContent);

break;

}

}

log(amkey, "The attachment " + attachmentContent, null);

} catch (Exception e) {

log(amkey, " Attachment not found ", e);

throw new ModuleException("Unable to retrieve the atachment payload"e"...exit module");

}

Please let me know how to resolve this error and also how can i retrieve the attachemnt payload.

Regards,

Meenakshi

Accepted Solutions (1)

Accepted Solutions (1)

former_member187339
Active Contributor
0 Kudos

Hi Meenakshi,

Are you using this module in the receiver communication channel? If yes then make sure you have checked the Read Attachments option in the operation mapping.

Regards

Suraj

Answers (2)

Answers (2)

former_member190389
Active Contributor
0 Kudos

Hi

First check if there are any attachements using



int i = msg.countAttachments();

//then try out

Payload  p = msg.getAttachment();

Former Member
0 Kudos

HI,

Add trace in your module code for debugging purposes.

Please check J2EE logs so that you can trace where exactly the error is coming from....

Regards,

Swetha.

Former Member
0 Kudos

hi,

i did that but it is giving the error unable to retrieve the attachment.nullPointerException.

regards

Meenakshi

former_member204873
Contributor
0 Kudos

hi,

Try using :

OutputMessage parseobj = new OutputMessage();

String content = content + parseobj.parseMessage(attachment.getInputStream());

Please check following blog:

/people/yugapreetha.t/blog/2009/06/23/read-multiple-attachment-content-inside-adapter-module

Thanks!!

Former Member
0 Kudos

Hi

Could you let me know exactly how to add trace to the module ? Is it done in the code or some other setting?

Thanks

Former Member
0 Kudos

Hi

Could you let me know exactly how to add trace to the module ? Is it done in the code or some other setting?

Thanks

Former Member
0 Kudos

hi,

i added audit logs to the the module code and printed the error message through it.

Regards,

Meenakshi