Ahmet Karakaya
Ahmet Karakaya

Reputation: 10149

What cannot be done without EJB

If JPA does not depend on EJB and it has its own spec. Why do I need EJB ? What I cannot without EJB ?

I have read the following discussions but I really do not point out why it is still required ?

Why should we use EJB?

https://stackoverflow.com/questions/4464338/why-ejb-is-used-in-enterprise-applications

Upvotes: 4

Views: 2401

Answers (3)

AlexR
AlexR

Reputation: 115418

EJBs, or enterprise java beans are java classes that can be managed by Java EE container that guarantees services like

  • bean life cycle
  • thread management
  • transaction management etc

Yes, JPA is not a part of Java EE spec now. It moved to JSE. However in past when Entity Beans provided the "standard" bridge between java and relational databases world.

What you cannot do without EJB? I'd say nothing. I mean you can do everything without EJB. And the reason is that there are alternative solutions like Spring or Guice.

And as always you can write lower level code without any framework.

Upvotes: 2

Shailendra
Shailendra

Reputation: 9102

All of the above answers add important information to the question but misses on one critical point. The main selling point of EJB architecture was distributed component (apart from all other services such as container managed,transactional, secure etc.). The idea was to enable the business logic to run in distributed environment piggybacking on RMI/IIOP. Although over the years this architectural style proved bad. For distributed computing there were more successfull architecture based on webservices. Distributed components though were made look easy by EJB, had their own share of inherent complexities and performance woes and were later avoided whenever possible. An old but very interesting read on this matter by Martin Fowler can be read here where he is scathing in his attack on the lure of distributed architecture typically being promoted by the likes of EJB. Later people seems to have followed this wisdom and avoided the temptation to jump onto the "distributed architecture" bandwagon. In Java landscape, this was marked by the rise of Spring framework and Rod Johnson's famous book "Expert One-on-One J2EE Development without EJB". People and the likes of me have never missed EJB's since then :-)

P.S. To be fair to EJB specs and the guys working hard on it to improve, they certainly have made fair progress in the past decade and they are much modern and developer friendly. However their "distributed" nature has taken a back seat for good

Upvotes: 3

HJK
HJK

Reputation: 1382

EJB is just a server side component that servers the request of the user. Each enterprise bean runs in a container which do some maintenance (transaction management, security management, bean life cycle etc.,) on behalf of the user/programmer. Thus it makes the developer to focus on the core job instead of reinventing all alone.

So we can conclude that EJB just reduces the amount of coding done by programmer and let the programmer to focus on the core business logic.

We can do the same without EJBs with some good amount of coding.

Thanks, JK

Upvotes: 2

Related Questions