API Connect

 View Only
  • 1.  Publish EJB as API

    Posted Tue July 05, 2022 01:03 PM
    Hello ,

    I work with IIB 9.0 and i want to publish my EJB as API .

    But I have an  error in the line 29 in my class (below)  the error is : cannot cast class java.lang.stub.java.rmi._Remote_Stub to interface ackNoAckHome

    Public class CallAckNoAckEJB_JavaCompute extends MbJavaComputeNode {

    public void evaluate(MbMessageAssembly inAssembly) throws MbException {
    MbOutputTerminal out = getOutputTerminal("out");
    MbOutputTerminal alt = getOutputTerminal("alternate");

    MbMessage inMessage = inAssembly.getMessage();

    // create new message
    MbMessage outMessage = new MbMessage(inMessage);
    MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly,outMessage);

    try {
    // ----------------------------------------------------------
    // Add user code below

    String response = null;
    String responseMessage = null;

    Properties properties = new Properties();
    properties.put(Context.PROVIDER_URL, "iiop://localhost:2809");
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.

    try {

    Context initialContext = new InitialContext(properties);
    Object obj = initialContext.lookup("ejb/com/acme/ejbs/AckNoAckHome");
    AckNoAckHome ejbHome = (AckNoAckHome)javax.rmi.PortableRemoteObject.narrow(obj,AckNoAckHome.class);

    AckNoAck ackNoAck = ejbHome.create();
    responseMessage = ackNoAck.getAck();
    response = "Ack";
    } catch(Exception e) {
    responseMessage = e.getMessage();
    response = "NoAck";

    MbElement cursor = outMessage.getRootElement().getFirstElementByPath("/XML/AckNoAck");

    // End of user code
    // ----------------------------------------------------------

    // The following should only be changed
    // if not propagating message to the 'out' terminal

    } finally {
    // clear the outMessage

    Best Regrads

    adil safieddine

  • 2.  RE: Publish EJB as API

    Posted Wed July 06, 2022 03:28 AM
    I think you might have posted this in the wrong group. I think you want App Connect, not API Connect.

    Try here: https://community.ibm.com/community/user/integration/communities/community-home?CommunityKey=77544459-9fda-40da-ae0b-fc8c76f0ce18

    Chris Dudley

  • 3.  RE: Publish EJB as API
    Best Answer

    IBM Champion
    Posted Wed July 06, 2022 04:32 AM
    There are so many things wrong with your approach...
    • IIB / ACE is not a J2EE server
    • Your JCN node will never work
    The right kind of approach would do this:
    • run the EJB in your J2EE server of choice
    • Have it consume the message put on a queue by IIB / ACE and put a response on a response queue if one is expected.
    • run a flow from IIB / ACE that you can publish to APIC => here is your EJB as service
      • The flow receives the call from APIC, if need be changes content and puts message to EJB queue
      • The flow receives Response from EJB as put to a reply queue, if need be, it changes the content and sends response to APIC
    Hope that helps some.

    Francois Brandelik

  • 4.  RE: Publish EJB as API

    Posted Wed July 06, 2022 05:26 AM
    Hi ,

    Thank you for your reply , but in may case the EJB it's not a MDB , we can use only RMI to get data from EJB 

    Best Regards