Thursday, April 28, 2011

B2B Callout - B2B runtime error: java.lang.IndexOutOfBoundsException

Recently I was approached with a B2B Callout error. The transaction fails with a Generic B2B error B2B-50029:  B2B runtime error: java.lang.IndexOutOfBoundsException.

Error Stack trace

[soa_server1] [ERROR] [] [oracle.soa.b2b.engine] Informational -:  B2B-50029:  B2B runtime error: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0[[ at oracle.tip.b2b.callout.B2BCalloutHandler.handleOutgoingCallout(    at oracle.tip.b2b.msgproc.Request.outgoingRequestPostColab(
            at oracle.tip.b2b.msgproc.Request.outgoingRequest(
            at oracle.tip.b2b.engine.Engine.processOutgoingMessageImpl(
            at oracle.tip.b2b.engine.Engine.processOutgoingMessage(


Looking at the error log, it was evident that the Callout java class was not populating the output list, which was causing the issue. When the B2B Outbound Handler tries to look up the output list it throws this java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 excpetion.

After you play around with the message then you should be populating the output message before exiting the execute method.

           CalloutMessage cmOut = new CalloutMessage(s);


The below code should fix the issue. We get the input, populate the output and return control back to B2B engine.

    public void execute(CalloutContext calloutContext, List input,
                        List output) throws CalloutDomainException,
                                            CalloutSystemException {
        b2blog(" Callout execute() called - Start");
        try {

            CalloutMessage cmIn = (CalloutMessage)input.get(0);
            String s = cmIn.getBodyAsString();
            b2blog((new StringBuilder()).append("Callout execute() - All Parameter = ").append(cmIn.getParameters()).toString());
            b2blog((new StringBuilder()).append("Callout execute() - CalloutMessage body = ").append(s).toString());

                //add logic of the task that needs to be done like archiving, manipulating the payload

           CalloutMessage cmOut = new CalloutMessage(s);
            b2blog((new StringBuilder()).append("Callout execute() - End Callout Testing = "));

        } catch (Exception e) {
            // System.out.println("Exception: "+ e.printStackTrace())
            b2blog((new StringBuilder()).append("Callout execute() - Exception = ").append(e).toString());


            throw new CalloutDomainException(e);

b2blog method call is explained in one of my previous blogs on B2B logging.

No comments: