Skip to Content
avatar image
Former Member

Adapter Development for Dynamic EOIO Queue

Hello All

I have developed the module to achieve Dynamic EOIO Queue.

I have deployed the module.

I am getting error = "An error occurred while processing message: 8b644171-fa18-4e01-1775-a4069728c0c3. The detailed error (if any): com.sap.aii.adapter.jms.api.channel.filter.MessageFilterException: while trying to invoke the method org.w3c.dom.Element.getChildNodes() of a null object loaded from local variable Elmnt1: NullPointerException: while trying to invoke the method org.w3c.dom.Element.getChildNodes() of a null object loaded from local variable 'Elmnt1' at com.sap.aii.adapter.jms.core.channel.filter.SendToModuleProcessorFilter.filter(SendToModuleProcessorFilter.java:95) ..."

Code

com.sap.adaptermodule;

java.rmi.RemoteException;

javax.ejb.EJBException;

javax.ejb.SessionBean;

javax.ejb.SessionContext;

javax.ejb.TimedObject;

javax.ejb.Timer;

org.w3c.dom.Document;

org.w3c.dom.Node;

org.w3c.dom.NodeList;

org.w3c.dom.Element;

java.io.InputStream;

javax.xml.parsers.DocumentBuilder;

javax.xml.parsers.DocumentBuilderFactory;

com.sap.aii.af.lib.mp.module.*;

com.sap.engine.interfaces.messaging.api.*;

public class DynamicEOIOBean implements SessionBean, TimedObject
{
      static final String c_param1 = "queuePrefix"; 
      static final String c_param2 = "Xmlnode";

      private static final long serialVersionUID=100L;

      /* (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 javax.ejb.TimedObject#ejbTimeout(javax.ejb.Timer)

       */

      public void ejbTimeout(Timer arg0) {

            // TODO Auto-generated method stub

      }

      public void ejbCreate() throws javax.ejb.CreateException
      {
      }


public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)throws

ModuleException
{
try
{

  String param1 = moduleContext.getContextData(c_param1);
  String param2 = moduleContext.getContextData(c_param2);

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

  Payload payload = msg.getDocument();

  InputStream inps = (InputStream) payload.getInputStream();

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

DocumentBuilder db = dbf.newDocumentBuilder();

Document doc = db.parse(inps);
doc.getDocumentElement().normalize();

NodeList nodeLst1 = doc.getElementsByTagName(param1);

NodeList nodeLst2 = doc.getElementsByTagName(param2);

Element Elmnt1 = (Element) nodeLst1.item(0);

Element Elmnt2 = (Element) nodeLst2.item(0);

NodeList ndLst1 = Elmnt1.getChildNodes();

NodeList ndLst2 = Elmnt2.getChildNodes();

String queueId;

if (ndLst1.item(0) != null)

      queueId = ndLst1.item(0).getNodeValue().concat(ndLst2.item(0).getNodeValue());

else

      queueId = msg.getSequenceId();


msg.setSequenceId(queueId);
inputModuleData.setPrincipalData(msg);

return inputModuleData;

} catch (Exception e) {
e.printStackTrace();

ModuleException me = new ModuleException("Unable to create Queue", e);

throw me;

}

}


}


Please help to resolve what need to change in code.

Thanks

Dheeraj Kumar

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 05, 2014 at 03:10 AM

    Hi Dheeraj,

    Can you share your input xml?

    It looks like that value for the parameters (param1 & param2) is not coming in your payload.

    In your code, you have assigned param1 and param2 value as constant value with "queuePrefix" and "Xmlnode". Check whether <queuePrefix> and <xmlnode> field is coming in your payload.

    Can you test by using below code and assign param1 and param2 value in channel?

    String param1 = moduleContext.getContextData("param1");

    String param2 = moduleContext.getContextData("param2");


    Make sure that parameter values coming in your payload.

    Please check this link Working with Module Configuration in SAP PI

    Regards,

    Praveen

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Praveen

      Thanks for all help.

      My prob is resolved with the code you provided.

      Now will work on concatinate function in this code.

      Thanks

      Dheeraj Kumar

  • Aug 06, 2014 at 06:55 AM

    Hello Dheeraj,

    I find that your source payload is idoc; but idocs doesn't support module development.

    Ajay Wandre

    Add comment
    10|10000 characters needed characters exceeded