RahulMohan82
RahulMohan82

Reputation: 559

How to configure an ejb both local and remote on Websphere

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?

Upvotes: 3

Views: 2358

Answers (3)

user1585676
user1585676

Reputation: 46

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 {}

Upvotes: 2

Brett Kail
Brett Kail

Reputation: 33946

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.

Upvotes: 1

Raul Lapeira Herrero
Raul Lapeira Herrero

Reputation: 987

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

Upvotes: 1

Related Questions