cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.NullPointerException

former_member204873
Contributor
0 Kudos

hi All,

I am getting following exception when i am using custom adapter module. How can i know where i.e. in which part of code this exception is raised.

2009-09-17 16:43:15 Information MP: processing local module localejbs/EJBModulePDF

2009-09-17 16:43:15 Error MP: exception caught with cause java.lang.NullPointerException

2009-09-17 16:43:15 Error Adapter Framework caught exception: null

2009-09-17 16:43:15 Error Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.NullPointerException.

Thanks,

Mayank

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

you need not deploy external jar on the PI server.you just add as external jars while creating the module

Former Member
0 Kudos

Imagine you would like to use 3rd party API in multiple custom-developed components... It is common (and best practice) to wrapp those jar files deployed in separate "external" DC and expose it centrally to other DCs using public parts. , instead of having the same functionality multiple times.

BR

Rudolf

Former Member
0 Kudos

you can trace by adding audit log

refer this /people/ganesh.karicharla2/blog/2008/02/20/adapter-module-development-module-configuration for how to add audit log


Example
   Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,
     "AO: Now got the xml payload object.")

you can see audit log that you add in the module in the RWB communication channel monitoring

former_member204873
Contributor
0 Kudos

hi,

My code is:

public ModuleData process(ModuleContext moduleContext,

ModuleData inputModuleData)

throws ModuleException {

Object obj = null;

Message msg = null;

MessageKey amk = null;

try {

obj = inputModuleData.getPrincipalData();

msg = (Message) obj;

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

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "EJBModulePDF: Module called");

}

catch (Exception e) {

ModuleException me = new ModuleException(e);

throw me;

}

try {

obj = inputModuleData.getPrincipalData();

msg = (Message) obj;

XMLPayload xpld = msg.getDocument();

String xmltxt = xpld.getText();

InputStream in = new ByteArrayInputStream(xmltxt.getBytes("UTF-8"));

Document doc = null;

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

DocumentBuilder db = dbf.newDocumentBuilder();

doc = db.parse(in);

NodeList list_Set=doc.getElementsByTagName("record");

NodeList list_Set1=doc.getElementsByTagName("EmployeeName");

NodeList list_Set2=doc.getElementsByTagName("EmployeeID");

NodeList list_Set3=doc.getElementsByTagName("Unit");

NodeList list_Set4=doc.getElementsByTagName("Role");

String input = "";

for(int i = 0; i < list_Set.getLength(); i++){

Node f=list_Set1.item(i);

f=f.getFirstChild();

String str_f=f.getNodeValue();

Node f2=list_Set2.item(i);

f2=f2.getFirstChild();

String str_f2=f2.getNodeValue();

Node f3=list_Set3.item(i);

f3=f3.getFirstChild();

String str_f3=f3.getNodeValue();

Node f4=list_Set4.item(i);

f4=f4.getFirstChild();

String str_f4=f4.getNodeValue();

input = input + str_f + "," + str_f2 + "," + str_f3 + "," + str_f4 + "END" ; }

// String input = (String) inputModuleData.getPrincipalData();

ByteArrayOutputStream baos = new ByteArrayOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(baos);

com.lowagie.text.Document document = new com.lowagie.text.Document();

try {

PdfWriter.getInstance(document,oos);

document.open();

PdfPTable table = new PdfPTable(4);

PdfPCell cell =

new PdfPCell(new Paragraph("Employee Details"));

cell.setColspan(4);

cell.setBackgroundColor(Color.red);

cell.setHorizontalAlignment(Element.ALIGN_CENTER);

table.addCell(cell);

cell = new PdfPCell(new Paragraph("Employee Name"));

cell.setBackgroundColor(Color.blue);

table.addCell(cell);

cell = new PdfPCell(new Paragraph("Employee ID"));

cell.setBackgroundColor(Color.blue);

table.addCell(cell);

cell = new PdfPCell(new Paragraph("Unit"));

cell.setBackgroundColor(Color.blue);

table.addCell(cell);

cell = new PdfPCell(new Paragraph("Designation"));

cell.setBackgroundColor(Color.blue);

table.addCell(cell); String inputArray[] = input.split("END");

for (int i = 0; i < inputArray.length; i++) {

String fieldValuesArray[] = inputArray<i>.split(",");

for (int j = 0; j < fieldValuesArray.length; j++) {table.addCell(fieldValuesArray[j].toString());}}document.add(table); }catch (DocumentException de) {

System.err.println(de.getMessage());}

document.close();

String xmlpld = document.toString();

XMLPayload sendpyld = null;

sendpyld.setText(xmlpld);

msg.setDocument(sendpyld);

inputModuleData.setPrincipalData(msg);

}catch (Exception e) {

ModuleException me = new ModuleException(e);

throw me;

}

return inputModuleData;

}

And i am able to se audit log in RWB.

2009-09-18 10:07:14 Information EJBModulePDF: Module called

2009-09-18 10:07:16 Error MP: exception caught with cause java.lang.NullPointerException

2009-09-18 10:07:16 Error Adapter Framework caught exception: null

2009-09-18 10:07:16 Error Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.NullPointerException.

How can i know where exactly null exception is raised.

former_member204873
Contributor
0 Kudos

hi,

I added audit logs in my code after every line, all the logs are visible in RWB MDT.

My last lines in the code are:

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "27");

return inputModuleData;

now exception coming is as follows:

2009-09-22 16:52:49 Information 27

2009-09-22 16:52:49 Error MP: exception caught with cause javax.ejb.RemoveException: An attemp was made to remove stateful instance while it still participates in a transaction.This is strictly forbidden by the EJB Specification. However the current transaction won't be marked for rollback allowing you to recover from the error.

2009-09-22 16:52:49 Error Adapter Framework caught exception: An attemp was made to remove stateful instance while it still participates in a transaction.This is strictly forbidden by the EJB Specification. However the current transaction won't be marked for rollback allowing you to recover from the error.

2009-09-22 16:52:49 Error Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: javax.ejb.RemoveException: An attemp was made to remove stateful instance while it still participates in a transaction.This is strictly forbidden by the EJB Specification. However the current transaction won't be marked for rollback allowing you to recover from the error..

2009-09-22 16:52:49 Information The message status was set to WAIT.

what does this error mean?

thanks,

mayank

Former Member
0 Kudos

Hi Mayank,

Check your bean type whether it is stateless or statefull and check this link

Regards

Ramesh

former_member270496
Participant
0 Kudos

hi Mayank,

i am facing sama problem as of yours which is listed below:

[ 08.08.2011 14:27:26 Error MP: Exception caught with cause java.lang.NullPointerException

08.08.2011 14:27:26 Error Exception caught by adapter framework: null

08.08.2011 14:27:26 Error Delivery of the message to the application using connection JDBC_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: java.lang.NullPointerException.

08.08.2011 14:27:26 Error The message status set to NDLV ]

please,tell me how you solved the problem?

Regards,

Raj Tripathy

Former Member
0 Kudos

Hi Mayank ,

Please check below SAP note which will provide you troubleshooting for your issue::

Note 1062037 - java.lang.NullPointerException error in Adapter activation

Thanks..

Mohit

former_member204873
Contributor
0 Kudos

hi,

I am using adapter module only and able to activate the channel, i am getting this error at runtime and also it is able to enter process method of module.

Thanks,

Mayank

Former Member
0 Kudos

Hi Mayank,

provide exception handling within your custom code and trace processing to identify at least the method, where exception is thrown. Be aware, that if you are using some external libs / jars in your custom module, those should be also deployed on PI. Otherwise you will get null pointer exceptions by doing instantiation.

Regards

Rudolf