File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes why we need EJB ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "why we need EJB ?" Watch "why we need EJB ?" New topic
Author

why we need EJB ?

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
1) why we need EJB ?
2 )can't we use normal java to Develop Enterprise application?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
Q1 isn't clear to me - nobody "needs" any particular API. Using it may help you implement your solutions, but it's certainly possible to get by without using it. Do you have an opinion on the matter?

As to Q2, what do you mean by "normal Java" - JSE (as opposed to JEE)? JEE is just a set of APIs and attendant capabilities on top of JSE - if those don't help your requirements, then -by all means- don't use them, or only use those that are actually useful to you.


Ping & DNS - my free Android networking tools app
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I mean can't we built a enterprise application without EJB , using J2SE ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
Well, I don't know what your definition of an "enterprise application" is, but I thought both parts of my post made it clear whether or not any particular API must be used; not so?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
anyway can you tell me what are the API use in J2SE and J2EE ?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I need to know when i am going to do a project when should i choose EJB ?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Samanthi perera wrote:anyway can you tell me what are the API use in J2SE and J2EE ?


The Sun java site has downloadable documents (javadocs) for JEE. The name is no longer J2EE.

I believe that the whole old-style J2EE design has fallen out of favor. It was never needed, and its not clear that it made things better.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
Pat Farrell wrote:I believe that the whole old-style J2EE design has fallen out of favor. It was never needed, and its not clear that it made things better.

Let's be precise: Old-style EJB (2.x) have fallen out of favor, and it's not clear that new-style EJBs (3.x) add much that can't be had by other means (like using JPA directly, without needing an actual EJB container). But JEE also defines lots of other APIs -like JavaMail, JMS, Servlets etc.- and those are still very much en vogue.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

To say what Ulf did in a different way,
JSE + EJB != JEE.

You need servlets to build a web application. It may not be a full JEE application, but it's certainly not a JSE one.


[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
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Ulf Dittmer wrote:Let's be precise: Old-style EJB (2.x) have fallen out of favor, and it's not clear that new-style EJBs (3.x) add much that can't be had by other means (like using JPA directly, without needing an actual EJB container).


Yes, to be clear, EJB were a bad idea, and were never needed.

Ulf Dittmer wrote: But JEE also defines lots of other APIs -like JavaMail, JMS, Servlets etc.- and those are still very much en vogue.


Servlets and JavaMail are used all the time. JSTL, etc. too .

I'm not all clear on why things like JavaMail are not part of the standard JDK libraries. They are very useful and unrelated to most of the other cruft in JEE.

I may not be "typical" but every professional Java application that I've written in the past decade has used servlets, and used them heavily. So for me, having them outside the standard JDK seems silly.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

EJB isn't bad idea.
If you say EJBs are complex, well that is mainly because it is trying to solve complex problems.
I agree that EJB 2.x are really pain in the *** to develop with but this isn't the situation with EJB 3.
I don't know what is the current state of EJB (is it used these days?) but to me, EJBs are noble creatures.
JavaMail should be part of JSE? definitely I agree with you.
Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
So for a 3-tier application, do we want EJB, or can/should we do without?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
can we do any EJB 3.0 application using Spring ?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

John Todd wrote:EJB isn't bad idea. If you say EJBs are complex, well that is mainly because it is trying to solve complex problems. I agree that EJB 2.x are really pain in the *** to develop with but this isn't the situation with EJB 3. I don't know what is the current state of EJB (is it used these days?) but to me, EJBs are noble creatures.


I do not know anything about EJB3 or any possible later versions. I was *so* traumatized by trying to use EJB six or more years ago that I still have nightmares.

One does not "solve" a complex problem by having a solution that is more complex than the initial problem. The only legit problem that EJB and J2EE were trying to solve was how do you write big, complicated web applications that have to scale to hundreds of thousands of users. It is possible that if you could ever implement a system using them, it might scale. But IMHO, EJBs were part of the problem, not part of the solution.

Back directly OT, NO, you do not need to use EJB.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Pat Farrell wrote:
I do not know anything about EJB3 or any possible later versions. I was *so* traumatized by trying to use EJB six or more years ago that I still have nightmares.

Hmm, we are talking about 2004 and beyond.
Yes Sir, I remember these days, EJB was for masochists but EJB development is really becoming easier and lighter with EJB 3.
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Samanthi perera wrote:
can we do any EJB 3.0 application using Spring ?


Spring is a different framework altogether, we dont even require a full fledged JEE application server to deploy a Spring application, a web container suffices. Infact you can execute a spring application in standalone mode.

I dont see any reason of using EJB if you are using developing your application using Spring.

Spring is an Open source framework where as EJB is a specification to which Application Server Vendors adher and provide their own APIs implementation

Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4338
    
    7

Pat Farrell wrote:I may not be "typical" but every professional Java application that I've written in the past decade has used servlets, and used them heavily. So for me, having them outside the standard JDK seems silly.

Well, servlets need a servlet container. The standard JDK doesn't. That, to me, seems a vaguely sensible dividing line, even if applications with servlets are more common than those without.
 
 
subject: why we need EJB ?
 
Similar Threads
When do we need EJB??
java
why do we need JNDI
@EJB
Purpose of EJB