Injected Context becomes invalid after a service reference is invoked in SwitchYard

Solution Verified - Updated -


  • If I have a Bean service that injects both the SwitchYard Context and a service reference, the Context becomes invalid after invoking an operation on the service reference.
@Service(value = OuterService.class)
public class OuterServiceBean implements OuterService {
    private Context context;

    @Inject @Reference
    private InnerService inner;

    public int getNumber(String in) {
        // This succeeds
        context.setProperty("FIRST", 1, Scope.EXCHANGE);
        // Invoke the referenced service
        int val = inner.parseNumber(in);
        // This fails since it is after the reference invocation
        context.setProperty("SECOND", 2, Scope.EXCHANGE);
        return val;
  • This service will throw an exception related to an invalid use of the Context:
java.lang.IllegalStateException: SWITCHYARD030422: Illegal call to get the SwitchYard Context; must be called within the execution of an ExchangeHandler chain.


  • Red Hat JBoss Fuse Service Works (FSW)
    • 6.0 (including roll-up patch #1-5)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content