cancel
Showing results for 
Search instead for 
Did you mean: 

RFC-Engine Service

Former Member
0 Kudos

Hi,

in Web AS there is a RFC-Engine service that enables ABAP programmers using session beans via RFC.

I´v found some information how to use this feature writing a Enterprise Portal service.

Is there also a description how to publish a "normal" session bean (not a portal service) as RFC method?

Thanks in advance

Helmut

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Can you guide me, how to use the RFC engine services. I need to download and upload the bundle configurations.

Regards,

mcsekar_21

Former Member
0 Kudos

Hi,

I solved this problem. The error was in the JCo library reference in the application deployment descriptor. It has to be com.sap.mw.jco instead of com.sap.mw.sapjco

Thomas

Former Member
0 Kudos

Hi Stefan,

We are trying to use the JCO RFC provide service to get ABAP call from SAP web AS (solution manager). And get the the similar problem which talked by you.

I create a destination named “acc”, and register a destination using sm59 on Solution Manager with the same programid, sapgateway, and gateway system number. I write and deploy a stateless EJB with the JNDI name same as the function name. But when I call this function from solution manager, it always raises exception

com.sap.mw.jco.JCO$Exception: (123) JCO_ERROR_FUNCTION_NOT_FOUND: JCO.Server could not find server function 'ACI_READ_SLD_DATA'

at com.sap.mw.jco.MiddlewareJRfc$Server.dispatchRequest(MiddlewareJRfc.java:1947)

at com.sap.mw.jco.MiddlewareJRfc$Server.listen(MiddlewareJRfc.java:1507)

at com.sap.mw.jco.JCO$Server.listen(JCO.java:6820)

at com.sap.mw.jco.JCO$Server.run(JCO.java:6749)

at java.lang.Thread.run(Thread.java:534)

(The function name “ACI_READ_SLD_DATA”) And in JNDI registry I can see the name “ACI_READ_SLD_DATA”.

It seems that the JCO server can not found the function in repository. But I don’t know how to add the function module the repository of this JCO Server.

And I do not know what should be set in the repository of the RFC destination in VA . Currently the repository set in the RFC Destination is some information about the WAS (Solution Manager).

I searched for more document for this issue, but did not get right information.

So I beg for you help. I will really appreciate if you can give us some help.

Thanks in advance.

Regards, Jackie Ju

roman_loshevsky
Active Participant
0 Kudos

Hello Helmut,

Could you provide information about how to use RFC-Engine service feature writing a Enterprise Portal service.

Thanks in advance,

Roman.

htammen
Active Contributor
0 Kudos

Hi Roman,

I unfortunately did only use the RFC engine service with a session bean using Stefan´s recipe.

But I would be surprised if Stefan doesn´t have an example or at least a description for you. Am I right, Stefan?

Regards

Helmut

Former Member
0 Kudos

Hi Helmut and Roman,

i don't have an example available, sorry. But there's documentation to access a portal service via RFC from ABAP <a href="http://help.sap.com/saphelp_nw04/helpdata/en/01/90fd3f0521c842e10000000a1550b0/frameset.htm">here</a>.

Best Regards

Stefan

Former Member
0 Kudos

Hi Roman

Were you successfull in calling a Portal Service from ABAP. I follwed the documenation given in the Link by Stefan.

I am gettting this error:

com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method processFunction

Did you get this error...

Regards

Senthil

Former Member
0 Kudos

Hi Helmut,

documentation can be found here: http://help.sap.com/saphelp_nw04/helpdata/en/6a/82343ecc7f892ee10000000a114084/content.htm

Hope that helps.

Best regards

Stefan

htammen
Active Contributor
0 Kudos

Hi Stefan and everybody else,

your hint helps a bit but I don´t know the details yet.

What does for example this mean:

The JCo RFC Provider Service calls the processFunction(JCO.Function) method of the EJB found.

Do I have to implement a special Interface in the stateless session bean?

It would be great to get an example or detailed description rather than getting an abstract description like provided by the online help.

I want to write a sessin bean that updates a database table. This session bean should be called from an R/3 4.6C System.

Does anyone have a more detailed description?

Regards

Helmut

Former Member
0 Kudos

Hi Helmut,

sorry for being this compact Yes, the session bean has to provide this method.

Here's a sample with a little management around it (it's also getting much longer now).

This should give you the direction how to implement such a bean.

Put the functionality for DB access in a specialized handler class and process parameter validation and call itself there.

1. Bean class

public class RfcSampleBean implements SessionBean {

  /** Expected JNDI name of this bean (equals RFM name) */
  public final static String JNDI_NAME = "RFC_SAMPLE_BEAN";

  /* Std EJB methods ommitted */

  /**
   * Business Method.
   */
  public Function processFunction(Function function) throws J2EEAbapException, EJBException {
    try {
      IRemoteFunctionRequestHandler handler = new RfcSampleHandler(function, JNDI_NAME);
      function = handler.handleCall();
    } catch (J2EEAbapException abapEx) {
      throw abapEx;
    } catch (Exception ex) {
      ex.printStackTrace();
      throw new EJBException(ex.toString());
    }
    return function;
  }
}

2. The bean class uses a specialized handler class for function processing:

public class RfcSampleHandler extends CommonRFRHandler {

  /** Expected import, export parameters and exceptions */
  private final static String IMP_FIRST_NAME = "FIRST_NAME";
  private final static String IMP_LAST_NAME = "LAST_NAME";
  private final static String EXP_FIRST_NAME = "FIRST_NAME_UPPER";
  private final static String EXP_LAST_NAME = "LAST_NAME_UPPER";

  private final static String EXC_ILLEGAL_ARGUMENTS = "ILLEGAL_ARGUMENTS";

  /**
   * @param function
   * @param jndiName
   * @throws J2EEAbapException
   */
  public RfcSampleHandler(Function function, String jndiName) throws J2EEAbapException {
    super(function, jndiName);
  }

  /* (non-Javadoc)
   * @see de.ascoit.rfc.sample.util.IRemoteFunctionRequestHandler#validateInputParameters(com.sap.mw.jco.JCO.ParameterList)
   */
  public void validateImportParameters(ParameterList input) throws J2EEAbapException {
    /* Expecting FIRST_NAME and LAST_NAME as input parameters */
    if (input == null
      || input.getString(IMP_FIRST_NAME).trim().length() == 0
      || input.getString(IMP_LAST_NAME).trim().length() == 0) {
      throw new J2EEAbapException(findInAbapExceptions(EXC_ILLEGAL_ARGUMENTS));
    }
  }

  /* (non-Javadoc)
   * @see de.ascoit.rfc.sample.util.IRemoteFunctionRequestHandler#validateExportParameters(com.sap.mw.jco.JCO.ParameterList)
   */
  public void validateExportParameters(ParameterList exp) throws J2EEAbapException {
    /* In reality export should be checked too (are fields existing) */
  }

  /* (non-Javadoc)
   * @see de.ascoit.rfc.sample.util.IRemoteFunctionRequestHandler#handleCall()
   */
  public Function handleCall() throws J2EEAbapException {
    JCO.Function result = super.getFunction();
    JCO.ParameterList imp = result.getImportParameterList();
    validateImportParameters(imp);
    JCO.ParameterList exp = result.getExportParameterList();
    validateExportParameters(exp);    
    exp.getField(EXP_FIRST_NAME).setValue(imp.getString(IMP_FIRST_NAME).toUpperCase());
    exp.getField(EXP_LAST_NAME).setValue(imp.getString(IMP_LAST_NAME).toUpperCase());
    return result;
  }
}

3. The abstract base handler class looks like this:

public abstract class CommonRFRHandler
  implements IRemoteFunctionRequestHandler {

  protected final static String EXC_COMMUNICATION_ERROR = "COMMUNICATION_ERROR";
  protected final static Location logger =
    Location.getLocation(CommonRFRHandler.class);
  private JCO.Function function;

  /**
   * Constructor for subclasses.
   * @param function Jco Function
   * @param jndiName Expected Jndi name
   * @throws J2EEAbapException on name mismatch.
   */
  protected CommonRFRHandler(JCO.Function function, String jndiName)
    throws J2EEAbapException {
    this.function = function;
    validateJndiName(jndiName);
  }

  /*
   * (non-Javadoc)
   * @see de.ascoit.rfc.sample.util.IRemoteFunctionRequestHandler#validateJndiName(java.lang.String)
   */
  public final void validateJndiName(String jndiName)
    throws J2EEAbapException {
    logger.infoT("Processing ABAP function call " + this.function.getName());
    if (!this.function.getName().equals(jndiName)) {
      logger.errorT(
        "ABAP function mapping invalid, ABAP name "
          + function.getName()
          + " mapped to JNDI name: "
          + jndiName);
      /* Use communication error for this */
      throw new JCO.J2EEAbapException(
        findInAbapExceptions(EXC_COMMUNICATION_ERROR));
    }
  }

  /*
   * (non-Javadoc)
   * @see de.ascoit.rfc.sample.util.IRemoteFunctionRequestHandler#findInAbapExceptions(java.lang.String)
   */
  public final JCO.AbapException findInAbapExceptions(String name) {
    JCO.AbapException[] exceptions = this.function.getExceptionList();
    if (exceptions != null && exceptions.length > 0) {
      for (int ix = 0; ix < exceptions.length; ix++) {
        if (exceptions[ix].getKey().equals(name)) {
          return exceptions[ix];
        }
      }
    }
    return null;
  }

  /* 
   * (non-Javadoc)
   * @see de.ascoit.rfc.sample.util.IRemoteFunctionRequestHandler#getFunction()
   */
  public final Function getFunction() {
    return this.function;
  }
}

4. In this case all RFR handler classes implement this interface:

public interface IRemoteFunctionRequestHandler {

  /**
   * Validates the function name a bean is called against the expected 
   * mapped JNDI name (avoids calling bean A as B)
   * @param jndiName expected mapped name of function
   * @throws JCO.J2EEAbapException if there's a mismatch
   */
  void validateJndiName(String jndiName) throws J2EEAbapException;

  /**
   * Validates import parameters of function call.
   * @param imp Parameter list
   * @throws JCO.J2EEAbapException if there are any invalid import params.
   */
  void validateImportParameters(JCO.ParameterList imp) throws JCO.J2EEAbapException;

  /**
   * Validates export parameters of function call.
   * @param exp Parameter list
   * @throws JCO.J2EEAbapException if there are export params missing.
   */
  void validateExportParameters(JCO.ParameterList exp) throws JCO.J2EEAbapException;

  /**
   * @return the requesting function for subclasses.
   */
  JCO.Function getFunction();

  /**
   * Handles the call.
   * @return Jco function, output parameters/tables correctly set.
   * @throws JCO.J2EEAbapException on any error handling the call.
   */
  JCO.Function handleCall() throws JCO.J2EEAbapException;

  /**
   * Returns the abap exception for a given name. 
   * @param name Name(key) of abap exception.
   * @return exception or null if not found.
   */
  JCO.AbapException findInAbapExceptions(String name);
}

5. The JNDI name of RfcSampleBean must be set to "RFC_SAMPLE_BEAN" in ejb-j2ee-engine.xml.

6. EJB Module and Ear project must get library references to Jco and Logging (weak references in case of Ear)

7. Other administrative tasks to make the bean usable are described in the documentation (RFC destination and Repository creation). It should be possible to use this from a 4.6c system also via RFC destination.

Hope that helps.

Regards

Stefan

htammen
Active Contributor
0 Kudos

Thanks Stefan,

that´s a great answer like I´m used from you

But I have one more question.

The adminstration manual says that I have to configure the RFC Provider Service that it is registered at a gateway on startup.

As I know there is only a gateway server if I´m using the ABAP stack. I do have a J2EE alone installation.

Can I configure the RFC Provider Service against the gateway server of my 4.6c system?

Thanks in advance again

Helmut

Former Member
0 Kudos

Hi Helmut,

if i understood the concept of the RFC provider service right, the RFC destinations defined in the Visual admin are used to retrieve the metadata of the function module interface from a R/3 system, which calls (back) the J2EE engine using RFC.

The provider service acts more like a client here, using the repository of the remote system for building the JCO functions out of the remote repository.

Therefore the RFC destination is actually created in a R/3 system (4.6c or whatever) and the definitions are repeated when creating a RFC destination in the visual admin.

Best regards

Stefan

htammen
Active Contributor
0 Kudos

Hi Stefan and everybody else,

I´ve written and deployed the session bean with JNDI name "RFC_WF_STATUS".

Then I´ve configured JCo RFC Provider service against the gateway and repository of my R/3 system (4.6c) and created a RFC destination in my R/3 system (SM59). The test of the destination was successful (SM59). The gateway monitor (SMGW) displays the connection and says it´s CONNECTED.

Shouldn´t I see my RFM in transaction SE37 know? It´s not visible.

The following code of a sample ABAP program throws a dump (see the callstack) when calling the RFM.

data: firstname(20) type c, lastname(20) type c.

Call Function 'RFC_WF_STATUS'

destination 'HTNOTEBOOK'

exporting

FIRST_NAME = 'helmut'

LAST_NAME = 'tammen'

importing

EXP_FIRST_NAME = firstname

EXP_LAST_NAME = lastname.

write: 'Firstname:', firstname.

write: 'Lastname:', lastname.

SAP (R) - R/3(TM) Callstack, Version 1.0

Copyright (C) SAP AG. All rights reserved.

Callstack without Exception:

App : disp+work.EXE (pid=2652)

When : 5/27/2004 19:40:45.362

Threads : 2

Comuter Name : BTEXX11

User Name : SAPServiceID1

Number of Processors: 2

Processor Type: x86 Family 6 Model 8 Stepping 6

Windows Version: 5.0 Current Build: 2195

State Dump for Thread Id 974

eax=0000abc6 ebx=00000000 ecx=00012a58 edx=00000000 esi=77f88e68 edi=000003c0

eip=77f88e73 esp=01d4b908 ebp=01d4b92c iopl=0 nv up ei pl zr na po nc

cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246

function : NtWaitForSingleObject

77f88e68 b8ea000000 mov eax,0xea

77f88e6d 8d542404 lea edx,[esp+0x4] ss:2627a907=????????

77f88e71 cd2e int 2e

77f88e73 c20c00 ret 0xc

77f88e76 8bff mov edi,edi

FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name

01d4b92c 77e8b32b 000003c0 ffffffff 00000000 00b247a6 ntdll!NtWaitForSingleObject

01d4b99c 0064d2ca 00000000 005812cb 00000001 00000402 KERNEL32!WaitForSingleObject

01d4ba48 006aa88f 00d488d0 00d488b4 00000070 00d4884c disp+work!ab_rabax

01d4bdc0 006aa55d 00000001 00000000 00000006 01d4be10 disp+work!RfcExtendedReceive

01d4bde4 00580ad5 00000001 00581066 01d4be10 005812cb disp+work!ab_rfcreceive

01d4be20 0057dc52 1e4eab10 1e4eab18 1e4eab40 01d4c28c disp+work!ab_srchexception

01d4c318 00588c7f 00000000 00000000 00000000 00000008 disp+work!ab_jfunc

01d4f3e8 005fb6b9 00000000 00000000 01d4f418 00000001 disp+work!ab_extri

01d4f3fc 005fb4f0 00000000 00cbcec8 00000000 78025744 disp+work!ab_xevent

01d4f418 0067a164 490cda78 004d1f3b 7fdd8c4f 00caeeb0 disp+work!ab_trigg

01d4f430 004e65f2 490cda78 490ce4d8 490cda78 490ce4d8 disp+work!ab_run

Any ideas?

Thanks Helmut

htammen
Active Contributor
0 Kudos

Hi,

some additional information. Here is the output of the defaultTrace.trc log from the Web AS.

com.sap.mw.jco.JCO$Exception: (123) JCO_ERROR_FUNCTION_NOT_FOUND: JCO.Server could not find server function 'RFC_WF_STATUS'

at com.sap.mw.jco.MiddlewareJRfc$Server.dispatchRequest(MiddlewareJRfc.java:1897)

at com.sap.mw.jco.MiddlewareJRfc$Server.listen(MiddlewareJRfc.java:1458)

at com.sap.mw.jco.JCO$Server.listen(JCO.java:6248)

at com.sap.mw.jco.JCO$Server.run(JCO.java:6181)

at java.lang.Thread.run(Thread.java:534)

Configuration seems to be o.k.

But probably there is something wrong with the bean.

Regards

Helmut

Former Member
0 Kudos

Hi Helmut,

does the RFM definition for RFC_WF_STATUS exist in the R/3 system you defined as destination via the Visual admin? Maybe i'm totally wrong, but i think the sequence, if you call the J2EE engine via RFC from R/3 is (roughly):

1. R/3 calls the J2EE engine (JCo Provider) via RFC (destination).

2. The JCo Provider (as JCO server) retrieves the metadata information for the RFM from the repository in the R/3 system and creates a JCO.Function for calling the bean.

3. The JCo Provider does the lookup using the function name as JNDI name and calls processFunction(), transporting the results to the calling R/3 system.

So, if the RFM definition doesn't exist in the R/3 system, step 2 fails. This seems to be weird, but since there's no ABAP metadata repository in the J2EE engine, it's consequent somehow.

Hope that helps.

Regards

Stefan

htammen
Active Contributor
0 Kudos

Hi again,

it´s becoming a bit wierd. I´ve got the configuration and programming details so far. My systems (4.6c and Web AS 6.30 J2EE) can talk to each other.

But when executing the RFC from R/3 side I get the following exception at J2EE side:

Exception thrown :Exception thrown by application running in JCo Server

java.lang.RuntimeException: com.sap.engine.services.rfcengine.RFCException: Incompatible bean type - no 'processFunction' found

at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:176)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)

My EJB does definitely contain the processFunction method with the correct signature

public com.sap.mw.jco.JCO.Function processFunction(com.sap.mw.jco.JCO.Function function)

This method is also published by the remote AND local interface. I´ve decompiled the generated code in .../cluster/server/apps/sap.com/[bean name]/jars and .../applicationsjars to be sure that the classes enclose the method.

I´ve also decompiled the rfcengine classes to see what´s happening there. In method RFCDefaultRequestHandler.handleRequest the bean is looked up under ctx.lookup("rfcaccessejb/" + beanName).

rfcaccessejb/RFC_WF_STATUS references localejbs/RFC_WF_STATUS as can be seen in Visual Administrator.

For this bean the create() method is called that gives back the LocalObject.

Then this object is searched for the processFunction method via:

processFunctionMethod = ejbobject.getClass().getMethod("processFunction", sessionBeanParameterClasses);

where sessionBeanParameterClasses is

sessionBeanParameterClasses = (new Class[] {

com.sap.mw.jco.JCO$Function.class

});

The search of the function seems to fail.

The only difference I see is that the rfcengine is looking for

com.sap.mw.jco.JCO$Function.class


and I defined the method with

com.sap.mw.jco.JCO.Function

May this be the reason for my problem? How can I solve it?

Many thanks in advance

Helmut

Former Member
0 Kudos

Hi Helmut,

this is really weird.

First of all the expressions com.sap.mw.jco.JCO$Function.class and com.sap.mw.jco.JCO.Function result in the same class reference, they are just different notations for inner classes (the first one is produced by your recompiler).

Second, i've got all these things working some time ago (i extracted the code sample from there), i'll try to reproduce this behaviour.

In the meantime, the only possible reason i can imagine right now is, that the RFC engine reflection results in a JCO.Function class from a different classloader than the bean itself uses. Since two classes with identic names, but loaded by different classloaders are <b>not</b> the same, the bean provides a method returning a JCO.Function of the session bean classloader where the rfc engine expects a JCO.Function of RfcEngine's own Classloader.

This fails but should not be the case on the other hand, since they are both referencing the "com.sap.mw.jco" J2EE library and should get the JCO.Function.class from the library classloader.

Best regards

Stefan

Former Member
0 Kudos

Hi Helmut,

first of all, i was wrong of course in my last post, since the return type of a method is not part of the method signature and does therefore not influence the Class.getMethod() results. I looked at the rfcengine classes also and i think the problem is, that:[code]sessionBeanParameterClasses = (new Class[] {

com.sap.mw.jco.JCO$Function.class

});[/code] is done in the constructor of RFCDefaultRequestHandler, so the JCO.Function class ref is a reference to the class created by the classloader of the rfcengine (RFCCL). Further down in the method handleRequest() the context classloader is switched to the module classloader (MODCL) of the bean, but the reflection is done with the parameter class JCO.Function of the rfcengine classloader.

So, if RFCCL and MODCL are <b>not</b> the same, the reflection uses:[code]

method = ejb.getClass().getMethod("processFunction", new Class[] {JCO.Function.class(of RFCCL)});[/code]but the bean has a method:[code]method = ejb.getClass().getMethod("processFunction", new Class[] {JCO.Function.class(of MODCL)});[/code]So the method search fails if RFCCL != MODCL.

Possible solution: Please remove the local interfaces from the EJB module. The reference under rfcaccessejb/ should be the remote JNDI reference e.g. the function name, not localejbs/functionname. The ejb-jar.xml should look somehow like this:[code]<ejb-jar>

<description>EJB JAR description</description>

<display-name>EJB JAR</display-name>

<enterprise-beans>

<session>

<ejb-name>RfcSampleBean</ejb-name>

<home>de.ascoit.rfc.sample.RfcSampleHome</home>

<remote>de.ascoit.rfc.sample.RfcSample</remote>

<ejb-class>de.ascoit.rfc.sample.RfcSampleBean</ejb-class>

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

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

</session>

</enterprise-beans>

</ejb-jar>[/code]Hope that helps.

Best regards

Stefan

htammen
Active Contributor
0 Kudos

Hi Stefan,

you are the greatest and I´m ashamed.

After reading the whole task again, I saw that I forgot to set a reference to JCO in my EAR project.

After doing so the RFC communication worked well.

Please forgive me for all the inconvenience. We should meet some time (maybe at Tech Ed in Munich) and have a good old german beer. Of course I will pay.

Thanks again

Helmut

Former Member
0 Kudos

Hi Helmut,

nothing to be ashamed for (hmm, maybe a little bit)

I'm not sure right now, if i will be in Munich, but if so, this will probably cost you more than one beer...

Best regards

Stefan

SidBhattacharya
Product and Topic Expert
Product and Topic Expert
0 Kudos

1 . I am getting this error when I include a weak reference to com.sap.mw.jco and com.sap.tc.logging in the EAR file

#1.5#000802DA02BF004F0000000F00000D900003E1655DEDD6DC#1092250845361#System.err#sap.com/JCORfcProviderProjectEAR#System.err#Administrator#71#####SAPEngine_Application_Thread[impl:3]_5##0#0#Error##Plain### at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:170)#

2. If I remove the references to jco and logging I get this error

1.5#000802DA02BF00510000000100000D900003E1655FEF2EC6#1092250880602#com.sap.engine.services.rfcengine##com.sap.engine.services.rfcengine.RFCJCOServer.handleRequestInternal()#Administrator#71#####JCO.ServerThread-2##0#0#Error##Plain###java.lang.RuntimeException: com.sap.engine.services.rfcengine.RFCException: Incompatible bean type - no 'processFunction' found

at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:187)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:151)

As per your previous mails this seems to be related to the class loading policy, so If I add the jco lib reference to the EAR and the class loading policy is module then it should work, right?

Secondly you advised to remove the Localinterfaces for the bean too whereas the documention says use local interfaces. My bean has just remote interfaces. Could that be a problem?

Thanks

Sid

Former Member
0 Kudos

Hi Sid,

> 2. If I remove the references to jco and logging I

> get this error...

no, you'll need both library references in the EJB module project <b>and</b> the EAR project.

> As per your previous mails this seems to be related

> to the class loading policy, so If I add the jco lib

> reference to the EAR and the class loading policy is

> module then it should work, right?

Again, it's important that <b>both</b> the EAR and the module project have a library reference to JCo and Logging. You don't really have to take care about the class loading policy, it's done correctly for you by the request handler of the service.

> Secondly you advised to remove the Localinterfaces

> for the bean too whereas the documention says use

> local interfaces. My bean has just remote interfaces.

> Could that be a problem?

no, not really. The steps of the request handler calling your bean are roughly:

1. Gets the name of the JCO function and uses it as bean name for the lookup.

2. Lookups the home object by ctx.lookup("rfcaccessejb/" + name);

3. If found, sets the home object's classloader as current thread's context classloader and searches the create() method of the home object via reflection. Creates the session bean by calling the method.

4. Uses reflection to search for the processFunction(JCO.Function) method in the session bean and invokes the method with the current JCO function instance.

So the important things are, that

1. Your bean is visible under "rfcaccessejb/YOUR_FUNCTION_MODULE_NAME".

2. Your bean has the processFunction(JCO.Function) method.

3. Again, EAR and module project are referencing JCO.

Hope that helps.

Regards

Stefan

SidBhattacharya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Yes it did work when i included the references in the EAR and the JCO Destination service was restarted from the Visual Admin.

Thanks

Former Member
0 Kudos

Hi Stefan/Helmut,

I'm trying to make a call to Java EJB(SAP J2EE 6.40) from ABAP(CRM 4.0).

To make a java call (processFunction(JCO.Function)) from ABAP, as mentioned by you guys, I'm using JCo RFC Provider Service. When i make the call, i et the follwoing error "Bean Z_RFC_TEST" Not Found.

#1.5#001279C08202006B000000DD00000EA0000400BF081308F3#1126720380850#com.sap.engine.services.rfcengine##com.sap.engine.services.rfcengine.RFCJCOServer.handleRequestInternal()####ZC1#20163005 #25061EF2D18E4D26B3E23C6AC3C57137#Thread[JCO.ServerThread-2,10,SAPEngine_System_Thread[impl:5]_Group]##0#0#Error##Plain###java.lang.RuntimeException: com.sap.engine.services.rfcengine.RFCException: Bean Z_RFC_CALL not found

at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:188)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

#

#1.5#001279C08202006B000000DE00000EA0000400BF08130987#1126720380850#icss_b2c.com.sap.mw.jco##icss_b2c.com.sap.mw.jco####ZC1#20163005 #25061EF2D18E4D26B3E23C6AC3C57137#Thread[JCO.ServerThread-2,10,SAPEngine_System_Thread[impl:5]_Group]##0#0#Debug#1#/#Plain###[undefined|?][3] [JAV-LAYER] Exception in dispatchRequest( Z_RFC_CALL):java.lang.RuntimeException: com.sap.engine.services.rfcengine.RFCException: Bean Z_RFC_CALL not found

at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:188)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

#

#1.5#001279C08202006B000000DF00000EA0000400BF08130A23#1126720380850#icss_b2b.com.sap.mw.jco##icss_b2b.com.sap.mw.jco####ZC1#20163005 #25061EF2D18E4D26B3E23C6AC3C57137#Thread[JCO.ServerThread-2,10,SAPEngine_System_Thread[impl:5]_Group]##0#0#Debug#1#/#Plain###[undefined|?][3] [JAV-LAYER] Exception in dispatchRequest( Z_RFC_CALL):java.lang.RuntimeException: com.sap.engine.services.rfcengine.RFCException: Bean Z_RFC_CALL not found

at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:188)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

I'll greatly appreciate if you guys could tell me the required steps to resolve this problem.

Regards,

Vishal.

Former Member
0 Kudos

Hi Stefan,

first of all I must say that this is really a very informative thread concerning ABAP-Java connection via JCo and I wonder how someone should get this working without the information here. I searched the SAP library and found nearly nothing!

I had several problems described here and now I'm hanging at the deployment. I get the following exception when I try to deploy the session bean with the processFunction() method:

Cannot deploy application sap.com/HL21CIBFassade..

Reason: Errors while compiling:

/usr/sap/E45/JC00/j2ee/cluster/server0/apps/sap.com/HL21CIBFassade/EJBContainer/temp/temp1129277049670/de/mhb/hypoline21/dokumenterzeugung/HL21DokumentErzeugerObjectImpl0.java:179: package com.sap.mw.jco.JCO does not exist

public void processFunction(com.sap.mw.jco.JCO.Function arg1) throws RemoteException {

^

/usr/sap/E45/JC00/j2ee/cluster/server0/apps/sap.com/HL21CIBFassade/EJBContainer/temp/temp1129277049670/de/mhb/hypoline21/dokumenterzeugung/HL21DokumentErzeugerLocalLocalObjectImpl0.java:161: package com.sap.mw.jco.JCO does not exist

public void processFunction(com.sap.mw.jco.JCO.Function arg1) {

^

2 errors

; nested exception is:

com.sap.engine.services.ejb.exceptions.deployment.EJBFileGenerationException: Errors while compiling:

/usr/sap/E45/JC00/j2ee/cluster/server0/apps/sap.com/HL21CIBFassade/EJBContainer/temp/temp1129277049670/de/mhb/hypoline21/dokumenterzeugung/HL21DokumentErzeugerObjectImpl0.java:179: package com.sap.mw.jco.JCO does not exist

public void processFunction(com.sap.mw.jco.JCO.Function arg1) throws RemoteException {

^

/usr/sap/E45/JC00/j2ee/cluster/server0/apps/sap.com/HL21CIBFassade/EJBContainer/temp/temp1129277049670/de/mhb/hypoline21/dokumenterzeugung/HL21DokumentErzeugerLocalLocalObjectImpl0.java:161: package com.sap.mw.jco.JCO does not exist

public void processFunction(com.sap.mw.jco.JCO.Function arg1) {

^

2 errors

The processFinction() method in my bean has the following signature:

public void processFunction(JCO.Function jcoFunktion)

The SAP EAR deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE application-j2ee-engine SYSTEM 'application-j2ee-engine.dtd'>

<application-j2ee-engine>

<reference reference-type="weak">

<reference-target provider-name="sap.com" target-type="library">

com.sap.mw.sapjco

</reference-target>

</reference>

<reference reference-type="weak">

<reference-target provider-name="sap.com" target-type="library">

com.sap.tc.Logging

</reference-target>

</reference>

</application-j2ee-engine>

I wonder what you mean with "the module project must have the library references"? I didn't find a tag in the ejb-j2ee-engine.dtd where I can specify a library reference.

When I include the JCO Library I use to comile my sources into the EAR I don't get this deployment exception. However I get an exception when the bean is called from ABAP. So this cannot be the solution. I'm developing an Windows and deploy on IBM/AXP. Is it possible, that the libraries are different??

I wonder if I should/can/must declare any exceptions to be thrown by the method processFunction() because they are part of the signature? Is it possible to throw exceptions in this method? How should I otherwise pass the exceptions to ABAP? When I add an additional parameter for the error message or code I have to set these returning parameters in the catch block, but setting parameters may lead to JCO.Exception again.

I hope you are still reading this thread and have some hints for me

Thomas