Question

I have a stateless EJB SessionBean with bith @local and @remote annotations. The code is working fine in weblogic server. However on deploying it to Websphere it gives following exception.

bm.ejs.container.EJBConfigurationException: BUSINESS_INTERFACE_DESIGNATED_AS_BOTH_REMOTE_AND_LOCAL: 'oracle.odc.session.ODCSession'

The oracle.odc.session.ODCSession business interface class cannot be both remote and local.

Is there any workaround available to make it work without writing seperate EJBs for remote and local invocation?

Was it helpful?

Solution

One workaround is to have a base interface with the method declarations & then have a local interface & a remote inteface, which extend the base interface, e.g.

public interface MyEJBBase {
    public void foo();
    public void bar();
}

@Local
public interface MyEJBLocal extends MyEJBBase {}

@Remote
public interface MyEJBRemote extends MyEJBBase {}

OTHER TIPS

AFAIK there is no way, the error seems pretty descriptive.

From section 4.9.7 of the EJB 3.2 specification:

The same business interface cannot be both a local and a remote business interface of the bean.

You can use subinterfaces as a workaround:

public interface MyInterface { /* all the methods */ }
public interface MyRemoteInterface extends MyInterface { /* empty */ }

@Stateless
@Remote(MyRemoteInterface.class)
@Local(MyInterface.class)
public class MyBean { /* ... */ }

Note that the parameters and return values of the methods on the remote interface will be pass-by-value but the parameters and return values of the methods on the local interface will be pass-by-reference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top