File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Pass by Ref vs Value for a Local EJB that calls a Remote EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Pass by Ref vs Value for a Local EJB that calls a Remote EJB" Watch "Pass by Ref vs Value for a Local EJB that calls a Remote EJB" New topic
Author

Pass by Ref vs Value for a Local EJB that calls a Remote EJB

Chris Ren
Greenhorn

Joined: Jul 18, 2007
Posts: 3
Say I have a servlet which invokes a method on an EJB (EJBA) via Local interface. This method in turn calls a method on a second EJB (EJBB) via a Remote interface. Assuming the code below, and that Ticket is Serializable, what should the System.outs be?

Heres what I'm seeing:
Point 1: Set by Servlet
Point 2: Set by Local EJB

It looks like foo(...) is pass by value even though its a local ejb, which I think is incorrect. I understand that the call to bar(...) will be a pass by Value, as it is a remote ejb call.

foo2(...) is working as expected.

I'm running on WebSphere 6.0 if that matters.

servlet:
Ticket t = new Ticket();
t.setValue("Set by Servlet");
// ... get Local EJBA reference
ejbALocal.foo(t);
System.out.println("Point 1: " + t.getValue());
ejbALocal.foo2(t);
System.out.println("Point 2: " + t.getValue());


EJBA:
public void foo(Ticket t)
{
// ... get Remote EJBB reference
t = ejbB.bar(t);
}

public void foo2(Ticket t)
{
t.setValue("Set by Local EJB");
}

EJBB:
public Ticket bar(Ticket t)
{
t.setValue("Set by Remote EJB");
return t;
}
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9955
    
163

Hello "Axis of Weasel"

Welcome to JavaRanch

We are glad to have you here. We have a naming policy at JavaRanch. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Please take a moment to change it, which you can do right here.


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9955
    
163

I'm running on WebSphere 6.0 if that matters.


If i remember correctly, you have to enable "Pass by reference" for the server profile from the admin console. The steps are as follows (i got these from one of the documents i have for WebSphere 6.0.1):

- Login to admin console
- On the left navigation bar, go to Servers -> Application servers.
- Under Preferences click server1.
- Under Container Settings, expand Container Services.
- Click ORB Service.
- At the bottom of the screen, select the Pass by reference checkbox.
- Click Apply.
- Click the Save link in the Messages section.
- To complete saving, click Save.
Chris Ren
Greenhorn

Joined: Jul 18, 2007
Posts: 3
but by J2EE standards, shouldn't all Local EJB calls be pass by reference and all Remote EJB calls by pass by value?

foo() should be a pass by reference callbut it isnt acting that way.

btw, thanks for the WS setting, i;ll check it out tomorrow.
 
Consider Paul's rocket mass heater.
 
subject: Pass by Ref vs Value for a Local EJB that calls a Remote EJB
 
Similar Threads
serialization
Mock question about business interfaces
Accessing ejb's with local home and remote interfaces
Dynamic query problem in WAS 6.0
Is it possible that servlet uses local interface of EJB2.0?