cancel
Showing results for 
Search instead for 
Did you mean: 

Adapter Module Error

Former Member
0 Kudos

Hi All,

I have been developed Adapter Module in NWDS 7.0 and deployed in PI 7.1 . All related Jar files (AF Pi 7.1) have been used and created EJB EAR projects and deployed. When I run the Scenario in Sender Communication channel i couldnt able to see payload it shows error I have been attached the same. When i check in moni also inbound message payload nthng is there it is blank. Could anybody tell me why it is like that? Is there any wrong in code i donot recievr any errors while creating EJB. Hence i donot know much java i have been followed the code which is from SDN Blog.And one more doubt like when I create class i have added Module Interface and then try to deployed but it did not deploy and we got error like:

Bean Interfaces: stateless bean "AdapterModuleXLRead" should have at least one of the following interface pairs: "local" and "local-home", "home" and "remote" or service endpoint interface, file: AdapterModule_EJB.jar#META-INF/ejb-jar.xml, column 0, line 0, severity: error

Hint: 1) Given application file is not valid one.

What i have done is like added ModuleRemote,ModuleLocal,ModuleHome,ModuleLocalHome while creating class. After that i have been deployed. Will this effect above ?

Regards,

Aparna.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

>>When I run the Scenario in Sender Communication channel i couldnt able to see payload it shows error I have been attached the same. When i check in moni >>also inbound message payload nthng is there it is blank. Could anybody tell me why it is like that?

Did you tried deploying xpi_inspector_ear for more log ?

Cheers

Agasthuri

Former Member
0 Kudos

Hi Agasthuri,

Thanks for reply.

I think everything is fine only the problem is it is not calling convert method. When you see code:

AuditLogStatus.SUCCESS,"AO: Now calling the Convert Method to convert Excel to XML.");
       byte by[] =

convert(xp.getContent(),msgType,nameSpace);

then it will call convert method .

When i test the cc i can able to see audit log mesage "Now calling the Convert Method to convert Excel To XML".

Aand after that iam getting exception as "Exception in Convert Method  "

When it call convert method exception raising and even iam not getting

audit message :Conversion Started also.

So i doubt it is not taking Excel content so anybody help me on this why convert method is not working is there any error in program. Excel file is in extension xslx format.

Regards,

Aparna.

former_member214364
Active Contributor
0 Kudos

Hi Aparna,

When you call the method convert you specified InputStream (output of xp.getContent() is InputStream object)as first argument but in method implementation first argument is byte src[].

How InputStream will get converted into Array of bytes automatically?

I guess you need to change arguments in convert method implementation as follows

convert(InputStream inpst,String msgType,String nameSpace)

{

   //Convert InputSteam into ByteArrayInputStream

  byte currentXMLBytes[] = inpst.toString().getBytes();

  ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);

..................

..........................

}

Please lets know if there are any issues.

Regards,

Jag

Former Member
0 Kudos

Thanks for quick reply jagadish and Amit.

@ Jagadish: Pls find below code for converting Excel to XML. We are getting Excel file and I had written adapter module which i have got in SDN.

package com.sap.adptermodule;

/**

* @ejbHome <{com.sap.aii.af.lib.mp.module.ModuleHome}>

* @ejbLocal <{com.sap.aii.af.lib.mp.module.ModuleLocal}>

* @ejbLocalHome <{com.sap.aii.af.lib.mp.module.ModuleLocalHome}>

* @ejbRemote <{com.sap.aii.af.lib.mp.module.ModuleRemote}>

* @stateless

* @transactionType Container

*/

import java.io.ByteArrayInputStream;

import javax.ejb.CreateException;

import javax.ejb.SessionBean;

import javax.ejb.SessionContext;

import jxl.Cell;

import jxl.Workbook;

import com.sap.aii.af.lib.mp.module.Module;

import com.sap.aii.af.lib.mp.module.ModuleHome;

import com.sap.aii.af.lib.mp.module.ModuleContext;

import com.sap.aii.af.lib.mp.module.ModuleData;

import com.sap.aii.af.lib.mp.module.ModuleException;

import com.sap.engine.interfaces.messaging.api.Message;

import com.sap.engine.interfaces.messaging.api.MessageKey;

import com.sap.engine.interfaces.messaging.api.XMLPayload;

import com.sap.engine.interfaces.messaging.api.MessageDirection;

import com.sap.aii.af.service.auditlog.Audit;

import com.sap.engine.interfaces.messaging.api.auditlog.AuditAccess;

import com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;

public class  AdapterModuleBean implements SessionBean, Module
{
  private SessionContext myContext;
  MessageKey amk;
  public void ejbRemove()
  {
  }
  public void ejbActivate()
  {
  }
  public void ejbPassivate()
  {
  }
  public void setSessionContext(SessionContext context)
  {
   myContext = context;
  }
  public void ejbCreate() throws CreateException
  {
  }
  public ModuleData process(
    ModuleContext mc,
    ModuleData imd)
    throws ModuleException {
    Object obj = null;
    Message msg = null;
    String msgType = null;
    String nameSpace = null;
    try {
       obj = imd.getPrincipalData();
       msg = (Message) obj;
       msgType = (String) mc.getContextData("msgType");
       nameSpace = (String) mc.getContextData("nameSpace");
     
       if (msg.getMessageDirection()== MessageDirection.INBOUND)
      amk = new

MessageKey(msg.getMessageId(),MessageDirection.INBOUND);

  else
      amk = new

MessageKey(msg.getMessageId(),MessageDirection.OUTBOUND);
     
       XMLPayload xp = msg.getDocument();
       Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Now

got the xml payload object.");
       if (xp != null)
       {
       Audit.addAuditLogEntry(amk,

AuditLogStatus.SUCCESS,"AO: Now calling the Convert Method to convert Excel to XML.");
       byte by[] =

convert(xp.getContent(),msgType,nameSpace);
       Audit.addAuditLogEntry(amk,

AuditLogStatus.SUCCESS,"AO: Conversion Done Successfully.");
       xp.setContent(by);
       }
       imd.setPrincipalData(msg);
       Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO:

Principle data is set successfully.");
    } catch (Exception e)
    {
     Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Module

Exception Caught .");
     ModuleException me = new ModuleException(e);
     throw me;
    }
    return imd;
    }

public byte[] convert(byte src[],String msgType,String nameSpace) throws Exception
  {
  String xmldata = "";
  try
  {
     ByteArrayInputStream byteArr= new ByteArrayInputStream(src);
     Workbook wb = Workbook.getWorkbook(byteArr);
     Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Conversion

Started.");
     xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"+ "<ns0:"+msgType+"

"+"xmlns:ns0=\""+nameSpace+"\">";
     Cell[] cells ;
     Cell[] cellNames ;
     cellNames = wb.getSheet(0).getRow(0);
     for(int j=1;j<wb.getSheet(0).getRows();j++)
     {
     xmldata = xmldata+"<Record>";
     cells = wb.getSheet(0).getRow(j);
     for(int i=0;i<wb.getSheet(0).getColumns();i++)
     {

xmldata =

xmldata+"<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">";
     }
     xmldata = xmldata+"</Record>";
     }
     xmldata = xmldata+"</ns0:"+msgType+">";  
     wb.close();
   }
   catch (Exception e)
   {
   Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,"AO: Exception in Convert

Method.");
   }
   return xmldata.getBytes();
  }
}

@Amit: Could please tell me why it is not possible. We created EAR(EJB) files with use of PI 7.1 AF jar files . It is an EAR file and it is not possible to deplooy through from NWDS 7.0 to PI 7.1 so we had given this to basis team to deploy and they deployed in J2EE engine.Hence we are using PI 7.1 AF jar files so we can create EJB & EAR in any environment such as eclipse or NWDS 7.0 or NWDS7.1. This is what my understand please let me know if iam worng.

Regards,

Aparna.

peter_wallner2
Active Contributor
0 Kudos

Hello Aparna,

What does your "ejb-jar.xml" look like? Make sure the following entries are there:

...

            <home>com.sap.aii.af.lib.mp.module.ModuleHome</home>

            <remote>com.sap.aii.af.lib.mp.module.ModuleRemote</remote>

            <local-home>com.sap.aii.af.lib.mp.module.ModuleLocalHome</local-home>

            <local>com.sap.aii.af.lib.mp.module.ModuleLocal</local>

            <ejb-class>com.adapter.usermodule.ConvertExcelToXMLBean</ejb-class>

            <session-type>Stateless</session-type>

            <transaction-type>Container</transaction-type>

...

Best regards,

Peter

Former Member
0 Kudos

Hi Aparna,

For the very first time (3 years back) when I digged into adapter module development I had read it somewhere that  backward compatibility does not exist between NWDS and PI versions(may be i will try to find out that source) and to be very precise i also haven’t tried it till yet and may not be wrong if I would say that I am bit reticent to cross check this also..

May be experts can throw some light on this.

And regarding ur issue as stated already cross chk the references which u have used in ejb-jar.xml file.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Peter,

It looks like the same.

Former Member
0 Kudos

Thanks Amit.

This was the case when i intially follow up the link from :

http://www.saptechnical.com/Tutorials/XI/Adapter/Index.htm . In this link  it is mentioned like When we create class we need to add Module Interface so when i add it while deploying this EAR fle in XI it is throwing error as shown above.

      After that i have been added ModuleHome,ModuleLocal,ModuleRemote,ModuleLocalHome interfaces to EJB Project. In this case it is successfully deployed. Here my issue was i can able to see audit log messages which are in class but when i try to open Payload in Sender CC it shows error  and there is no XML I Doubt there may be program error in class which is written for Excel to XML Conversion.

     And One more thing also i wish to ask all In the above link it has mentioned like we need to add Module Interface. In the link of How to create modules for the JEE Adapter Engine PI 7.1 It has mentioned like ModuleHome,ModuleLocal,ModuleRemote,ModuleLocalHome have to be added and finally we have to delet from build foledr. This i understood since those interfaces are available in PI 7.1 AF. Why in the PI 7.0 we donot need to add those interfaces.

Regards,

Aparna.

former_member214364
Active Contributor
0 Kudos

Hi Aparna,

why dont you try the procedure given in the following document for creating Adapter module.

http://scn.sap.com/docs/DOC-16229

I have followed this document in past and worked without any issues.

Regards,

Jag

Former Member
0 Kudos

HI ,

I have followed up the same but in NWDS 7.0 i have craeted this. I doubt Excel to XML conversion class is not working or else y it will not show payload in Sender CC.Thoughts from anyone? Pls share ..

former_member214364
Active Contributor
0 Kudos

Hi Aparna,

Have you tried displaying output of the method process(....). i mean just write payload to audit log before return imd; statement.

This might give some idea.

Regards,

Jag

Former Member
0 Kudos

Hi,

AFAIK (and if i am not wrong) you cant use NWDS7.0 to create/deploy modules on PI7.1 and also cross chk the interfaces reference which u have used in ejb-jar.xml file

Chk this article which shows how to create adapter modules for PI7.1     :

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0b39e65-981e-2b10-1c9c-fc3f8e674...

Thanks

Amit Srivastava

former_member214364
Active Contributor
0 Kudos

Hi Aparna,

Could you please explain the functionality of Adapter module in your situation or send atleast module code.

Regards,

Jag