cancel
Showing results for 
Search instead for 
Did you mean: 

Null pointer exception in custom adapter module

Former Member
0 Kudos

Hi ,

I am developing an adapter module for attaching an image file to the payload. But when i am trying to test my adapter module i am getting the following exception:

MP: exception caught with cause java.lang.NullPointerException

I have configured my adapter module with sender file adapter. I just want to test my module. The module tries to establish an ftp connection , pick a file from ftp location then attach the file to the payload and send.

The code for ftp connection and picking the file is working fine , i have tested it by posting the file to another folder location.

But whenver i try to create the msg object via

msg = (Message ) inputModulePayload.getPrincipleData();

The msg object is null, and then this throws null pointer exception in the next line as i am trying to use the msg object.

Does any one has any idea why i am getting this null pointer exception ?

PS: in the sender communication i have added the cumtom adapter module with module key 1 and sap module is with key 0.

apart from tht there is not setting in the module configuration.


	 AuditAccess audit = null;
		 MessageKey key = null;
		 Object obj = null;
		 Message msg = null;
		 Payload payload = null; 

//    /   ModuleData mData = sendModuleData();
		try {
			// initializing the objects to read the data
		    obj = inputModuleData.getPrincipalData();
   		    msg = (Message) obj;
			audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();
  		    key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());

Thanks,

Anumeha

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member187339
Active Contributor
0 Kudos

Hi Anumeha,

>>in the sender communication i have added the cumtom adapter module with module key 1 and sap module is with key 0.

apart from tht there is not setting in the module configuration.

It should be the other way round.. first custom module (key 0) then sap module (key 1)..

Regards

Suraj

former_member184944
Participant
0 Kudos

Hi Suraj ,

I v tried the other way round also still im getting null pointer error

former_member190389
Active Contributor
0 Kudos

Could you add some traces in the audit log and then run and see where exactly the error comes and check .

Is it because you have not defined msg variable as static ?

former_member184944
Participant
0 Kudos

Hi ,

In order to create audit object i will have to create it using;

audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();

key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());

audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"GetAttachment: Module called");

but since my message object is not getting created , i cannot successfully write audit messags as well using the above code.

Also we cannot define Message object as static , you will get "Illegal modifier for parameter msg; only final is permitted" error.

former_member190389
Active Contributor
0 Kudos

Are you using PI 7.1?

former_member184944
Participant
0 Kudos

Yes im using PI 7.1 and i have used all lates jar files.

com.sap.aii.af.lib.mod.jar: <bin>/ext/com.sap.aii.af.lib/lib

sap.comtcloggingjavaimpl.jar: <bin>/system

com.sap.aii.af.svc_api.jar: <bin>/services/com.sap.aii.af.svc/lib

com.sap.aii.af.cpa.svc_api.jar: <bin>/services/com.sap.aii.af.cpa.svc/lib

com.sap.aii.af.ms.ifc_api.jar: <bin>/interfaces/com.sap.aii.af.ms.ifc/lib

former_member204873
Contributor
0 Kudos

hi,

Try to use this:

Message msg = (Message)inputModuleData.getPrincipalData();

XMLPayload xmlpayload = msg.getDocument();

String str = XMLPayload.getText();

Thanks.

Former Member
0 Kudos

This message was moderated.

former_member204873
Contributor
0 Kudos

This message was moderated.

former_member184944
Participant
0 Kudos

Problem solved. The custome module should be key 1.