It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes Ejb Beginner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Ejb Beginner" Watch "Ejb Beginner" New topic

Ejb Beginner

sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 126
I am new to Ejb, I have doubt why cant we implement methods in remote itself,why we need to go for separate bean class.
Sudharsan tettu
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441


Remote is an interface, which specifies the APIs available to the EJB client. The bean class is an implementation of this interface.

Let us know if you were looking for something else

[My Blog] [JavaRanch Journal]
sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 126
thank you for your reply
But my doubt is why Ejb is framed like that.
Whats real need for remote interface.....
why it is not directly bean . Why do we need remote in between client and a bean.

thank you
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
Originally posted by sudarsan tettu:
Why do we need remote in between client and a bean.thank you

Good question. You might want to check EJB 3.1 features.
Reza Rahman
Ranch Hand

Joined: Feb 01, 2005
Posts: 580

There are two simple reasons for EJB interfaces:

1. To enable stub objects injected into interfaces for unit/integration testing. That being said, EJB 3.1 introduces no-interface local beans.
2. To enforce loose-coupling between clients and implementation code. This is especially true for remote clients. I can't think of a single technology, Java or otherwise, that allows direct access to implementation objects for remote clients.


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Schandha Ravi
Ranch Hand

Joined: Oct 20, 2007
Posts: 167
One more reason which I could see here . Enterprise Beans are not remote objects. Client and Enterprise beans do not share same heap and hence clients can not communicate directly to enterprise beans. So we have remote and home interfaces to safe guard enterpise beans from any direct interaction. As per Head First EJB, remote interface is like a body guard to enterprise bean and every communication should go only through him. If at all anything can communicate to enterprise bean it can be only container.

Thanks & Regards, SK
SCJP 5.0, DB2 - 800, DB2 - 803, SCDJWS (On the way)
Hari Dhanakoti
Ranch Hand

Joined: Jan 07, 2008
Posts: 74
Hi all,

I have a doubt please clear...

As per EJB 3.1 we don't have the need to implement the local and the remote interfaces to the session bean which we need to make use of the remote and the local interface methods.

I agree. Here's the link:
subject: Ejb Beginner
It's not a secret anymore!