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 EJB an Overhead? 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 "EJB an Overhead?" Watch "EJB an Overhead?" New topic
Author

EJB an Overhead?

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Hi Guys,

I had a peculiar doubt that why do we all the way need an EJB?. After all, its making code verbose. What are all the things we can do in EJB can be done with other options like Hibernate and Struts or Spring framework that can also run in non-managed environment. In the J2EE environment, EJB is safe, secure and transactional. But there are other ways to achieve these features..still why do we need an EJB.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


After all, its making code verbose. What are all the things we can do in EJB can be done with other options like Hibernate and Struts or Spring framework that can also run in non-managed environment.

A comparison between EJB and Struts is pointless, they share no common functionality. I would use Hibernate with EJBs (or at least, a JPA provider) so that code would be pretty much identical in either deployment. Is Spring less verbose than EJB3?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
It depends entirely upon what you are doing. Your question implies you desire to keep everything as simple as possible, which is good. There is a good book addressing this "Faster, Better, Lighter Java". I would stick with Tomcat if it did everything I needed, however moving to an application server has made our lives easier because it is better suited to support the work we are doing. In particular it is easier to manage more complex applications that rely on multiple underlying projects. It has also allowed us to move to a service oriented architecture utilizing RMI/IIOP and to integrate easily with other applications such as JBPM.

Good luck,
Stu

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Guys,

You are right..that i cant make everything as simple as possible. What i am saying is that what a session bean is doing in an Enterprise application can be written in Struts Action class..I can use APIs to give its transactional and security issues..isnt it?
Why we need an session bean to wrap up our code and looking up JNDI code to get the service..isnt it an overhead?? thats i am asking guys..

Or im entirely wrong understanding these things...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


What i am saying is that what a session bean is doing in an Enterprise application can be written in Struts Action class

No, it can't at least not easily. To replicate all the container provider services (and applicaiton management tools available in EJB containers) yourself is non-trivial. I think you may have a slightly oversimplified understanding of what functionality EJBs provide.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
I think i understand EJB has something to be worth considering...but i have a requirement to build a web application. Now In which scenario i should go for EJB and in which i should not..Because i can integrate Struts-hibernate-jsp/servlet and Database to complete my project..

Give me an exact example or scenario in which i must use EJB..
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

OK, why are you condisering EJB? What container provided services are you plannign to use?
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Thats what i am asking you guys..for which container services i should go for EJB? Or can I replace EJB?

For an Enterprise application, i have business tier.. I understand i should use EJB for the business tier..isnt it??? my question is that can i use other technologies(i dont know other technologies exist) to replace EJB?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No, your business logic can go wherever it makes architectural sense for it to go. If you are writing a simple web application EJB may very well be a considerable overhead. There are a lot of questions you can ask yourself which might point you in the direction of EJBs (or a simmilar technology); these are far to many to list completely here which is why I'm asking you what you think you might need. Since you use EJB for the container provided services EJBs give you access to, you need to ask which of these services will I be using? If the answer is "none" then you probably don't need EJBs (or Spring for that matter). If the answer is "I don't know" then you probably need to take a little time to review your overall architecture and have a think about it.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
fine paul. I think i should say "i have to give it a think.' Moreover please give some other technology options which i might use in place of EJBs..
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Well you have plain old java objects calling third party APIs that replace container provided services, or Spring (which is kind of the same thing). Again though neither of these routes are applicable if you don't need the container provided services in the first place.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90

Then can i conclude from your discussion that EJB is mere provider of container services? Because i thought it is that way it seems...So when i need container services for my application, i can use EJBs..??


Thanks for your so-far-clarification..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB an Overhead?
 
Similar Threads
Need for Service Locator
JCA resource Adapter and Web Services
Purpose of EJB
what is EJB used for? is Spring a replacement for EJB?
JNDI Lookup/ejb-jar.xml to find an another ejb