Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Chris Ren
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic