*
The moose likes EJB and other Java EE Technologies and the fly likes Local/Remote interface 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 "Local/Remote interface" Watch "Local/Remote interface" New topic
Author

Local/Remote interface

roul ravashimka
Ranch Hand

Joined: Mar 16, 2004
Posts: 53
hello all,
is the interaction between a servlet and a EJB possible by using the local interface of the ejb, of do you alwyas have to use the remote interface?

I hope someone could help me,
Roul


MSc Electronics, ICT
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Roul,
We just had this question at work yesterday. Sun says that it is possible to use the local interface between servlets and EJBs but not recommended.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
roul ravashimka
Ranch Hand

Joined: Mar 16, 2004
Posts: 53
thank you for your input,
but why isn't it recommended?
Roul
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

I can't find the sun link, but here is one from ibm and a discussion on the server side.
sam bos
Greenhorn

Joined: Feb 03, 2003
Posts: 12
There seems to be a logical reasoning behind it since.
You may use the local ref to remote object if the servlets are residing in the same JVM as your ejbs which ofcourse will give you a performance boost but what if you decided to scale your application by adding more processors in a cluster.
Your servlet container and ejb container both can reside on different machines in a cluster and obviously your ejbs cannot be local to your servlets.
I may be wrong but this is what i think.
-sam
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
Calling an EJB with the local interface from the Web Container is possible.
I recomend it. It is a matter of performance versus location transperency. I would choose performence since you will have the EJB and Web in the same layer most of the time anyway.


Roland Barcia: IBM Distinguished Engineer, CTO Mobile for Lab Services
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
Originally posted by Roland Barcia:
Calling an EJB with the local interface from the Web Container is possible.
I recomend it. It is a matter of performance versus location transperency. I would choose performence since you will have the EJB and Web in the same layer most of the time anyway.

I am curious how EJB and Servlet can be in the same layer(in the sense of clustered environment). They may look like that since they are both on the server side, but they both can be on two different virtual machines. But for a user they may seem virtually on the same layer(server side) but on two different JVMs. Only in small scale J2EE systems they are sitting on the same box, I would say.


Kishore
SCJP, blog
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Originally posted by Kishore Dandu:

I am curious how EJB and Servlet can be in the same layer(in the sense of clustered environment). They may look like that since they are both on the server side, but they both can be on two different virtual machines. But for a user they may seem virtually on the same layer(server side) but on two different JVMs. Only in small scale J2EE systems they are sitting on the same box, I would say.

Hogwash. In MOST large-scale J2EE systems (and I mean of the scale of Schwab, eBay, etc...) the Servlet and EJB containers are co-resident in the same JVM. We at IBM have been recommending this for several years. It's MUCH faster, and just as scalable as using a multi-tier system where you separate the Web and EJB containers. Yes, that's different from "Accepted wisdom", but in fact, we have the numbers and performance tests within IBM to back it up. In this case, the accepted wisdom is flat-out wrong.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Kishore Dandu:
Only in small scale J2EE systems they are sitting on the same box, I would say.

Absolutely wrong. Most large-scale J2EE deployments co-locate the EJB and Web tiers in the same JVM in the form of an Enterprise Application. This is the main motivation for standardizing EAR deployments in the J2EE 1.3 Specification. When large systems need to scale horizontally then the application is replicated across all nodes in the cluster.
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
Originally posted by Chris Mathews:

Absolutely wrong. Most large-scale J2EE deployments co-locate the EJB and Web tiers in the same JVM in the form of an Enterprise Application. This is the main motivation for standardizing EAR deployments in the J2EE 1.3 Specification. When large systems need to scale horizontally then the application is replicated across all nodes in the cluster.

So, what you guys are saying is, when there is clustering and there is a failover; the new jvm that takes the responsibility of serving the EJB and servlet will be the same. OK.
So, from 1.3 spec on; does that mean many large scale J2EE implementations are served by single JVM; before and after a failover???
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
Not exactly sure what you are referring to with serving, but you should look at it as the application (as a whole) is failing over. Issues with failover has to do with State Management. The fact that a Bean class or a Servlet are loaded in the same VM and are servicing the same client is different?
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

I am using local interfaces currently between my BusinessDelegates (webtier) and my SLSBs (EJBtier). But I want my BusinessDelegate code to easily switch from one to the other. I want to set a property in Ant (not sure where, web.xml ?) and then have that propagate to the delegates. Any suggestions?
Pho


Regards,

Pho
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
I never liked the idea of having the Remote/Local interfaces being a programmatic decision, I think this made the spec more complex for the client. Using some type of smart delegate is defintley that hides the details of weather it is local or remote is definitely adivisable. The spec should have made this a deployment decision and not a programmatic one.
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
Originally posted by Roland Barcia:
I never liked the idea of having the Remote/Local interfaces being a programmatic decision, I think this made the spec more complex for the client. Using some type of smart delegate is defintley that hides the details of weather it is local or remote is definitely adivisable. The spec should have made this a deployment decision and not a programmatic one.

may be that is why IBM websphere is lagging in technology compared to Weblogic (since some who are working for IBM don't agree a lot with the spec). This is just a joke.
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
BEA sees this as a limitation as well. Thus why we are co-authoring the SDO spec together to bring a common client model for multiple data sources.
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Roland,
What does SDO mean actually ?
Pho
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
Service Data Object
http://www.jcp.org/en/jsr/detail?id=235
http://www-106.ibm.com/developerworks/java/library/j-commonj-sdowmt/
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Local/Remote interface
 
Similar Threads
JNDI names for EJBs
Junit test EJB
Local - Remote switch
Local client can call another bean through its remote interface?
Session Beans & Entity Beans together