This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange EJB Behaviour

 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My servlet calls an ejb deployed in the same app server (WebLogic) passing reference to an object. This object is serializable and the its a remote call to the ejb.
I have oserved a difference in the state of the object when application is deployed as EAR and when it is deployed in exploded form.
Such a difference is not expected. The ejb should not be able to change the state.
Can you throw some light on this.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you elaborate on how the "EJB's state changes"?
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not the EJB, the Object whose reference is passed gets its state changed.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects are passed by reference when both the war and jar are in the same ear file.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by abhinav srivastava:
Not the EJB, the Object whose reference is passed gets its state changed.

uhhm :-(. I have heard that weblogic optimizes remote calls / rather calls to remote EJBs if it figures out that the caller and the EJb are in the same VM (by making it a local invocation).
Now I did'nt know that it does'nt respect the pass-by value semantics in that case. The pass by reference behaviour that you are referring to w'd have been ok if it had been an EJB with Local interfaces.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Objects are passed by reference when both the war and jar are in the same ear file.

Is this documented somewhere / is it there in some book ? I find this strange. When i use a remote EJB, dont I always program assuming that "pass-by-value" semantics will be respected. I mean the parameters passed to a remote EJb if serializable has to be a pass by value?
I guess many applications do have the war and the jar packaged together in a ear.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The specification states that remote calls should use pass-by-value. WebLogic deliberately breaks that part of the specification by default but provides a way of forcing pass-by-value: http://edocs.bea.com/wls/docs61/ejb/reference.html#1070257
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Weblogic Application Server is hosting both Servlets and EJBs. It seems that in case of an EAR file, its pass by refrence and in case of Exploded deployment its pass by value.
Haven't found any documentation in support of this though thats the way it is.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:
The specification states that remote calls should use pass-by-value. WebLogic deliberately breaks that part of the specification by default but provides a way of forcing pass-by-value: http://edocs.bea.com/wls/docs61/ejb/reference.html#1070257

you guys are just awsome! I guess the developers @ your place need not look up weblogic docs / EJB Spec when they code. They probably just have to turn and ask :-).
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you guys are just awsome! I guess the developers @ your place need not look up weblogic docs / EJB Spec when they code. They probably just have to turn and ask :-).

Thanks for the ego boost
By the way, WebSphere also has this pass-by-value/pass-by-reference switch (at least in the previous version) but I think the default behaviour was spec-compliant.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle 9iAS also supports pass by value.
You make use of copy-by-value tag in orion-ejb-jar.xml .
Whether or not to copy (clone) all the incoming and outgoing parameters in EJB calls. Set to 'false' if you are certain that your application does not assume copy-by-value semantics for a speed-up. The default is 'true'.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle 9iAS also supports pass by value.

All certified J2EE implementations must support pass-by-value. What they can support is the non-compliant pass-by-reference. Then there's the question of which one is the default.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry ..I typed it wrongly .. it is pass by reference
The default is pass by value as mentioned in my previous post.
[ August 14, 2003: Message edited by: Pradeep Bhat ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic