Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why we need EJB ?

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) why we need EJB ?
2 )can't we use normal java to Develop Enterprise application?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean can't we built a enterprise application without EJB , using J2SE ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway can you tell me what are the API use in J2SE and J2EE ?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know when i am going to do a project when should i choose EJB ?
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So for a 3-tier application, do we want EJB, or can/should we do without?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we do any EJB 3.0 application using Spring ?
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic