How To Use Ejb

CategoryEjb


There's a fair few projects out there using EnterpriseJavaBeans. What are the issues and decisions that people are facing and making? Populate this page with links to pages discussing various problems.

EntityBeans

If you are building system with EJB, EntityBeans are a new kind of animal. They are nice, but what is the best way to use them?

In particular how do you work with EntityBeans and business logic? I've heard of two approaches: EntityBeansAsDomainObjects and EntityBeansAsDataGateways.

Choice of Application Server

Our biggest issues are which ApplicationServer is the right one? How does one go about PickingAnEjbServer?

Unit testing enterprise beans

Unit testing in Java is quite straightforward except for the GUI parts. Facing development of EnterpriseJavaBeans it becomes harder to make sensible tests. See EjbUnitTest for a further discussion about this.


See WhatAreComponentsAnyway, EjbRoadmap.


EntityBean tips

Biggest problem with EntityBeans – marketing. Most people have the impression that EntityBeans are some kind of O/R mapping tool (RDBMS). NO! They were designed as a universal persistence layer. Even CMP should not be considered as an O/R approach; please note: the name stands for Container Managed Persistence, not Database. The EntityBeans persistence approach is far from being optimal for O/R mapping, but it is the ONLY solution possible that allows persist data in different storage systems (DB, LDAP, file, ERP-system, mainframe), and to have relationships between them, and do transactions.

Yes, most applications need just DB persistence, and more optimal solutions are possible. Do I mean CMP must not be used? No, just beware the N+1 problem (it is not a problem but a feature), and do not be afraid of using plain SQL and JDBC to get lists of information about objects. Note: not objects (!), but information about them, and only if the user or system really wants to do CRUD upon an object, use EntityBeans.

-- KonstantinIgnatyev


EJBs in Production

Does anyone have any details of where they have used EnterpriseJavaBeans in production? Specific reasons for using them over plain vanilla servlets or non-Java platforms? Perhaps a list of EnterpriseJavaBeansProjects?? see also: EjbCaseStudies


At IBM's Websphere2000 user conference held from March 26-29, 2000, in Miami, IBM trotted out a collection of Websphere customers to do the kiss-and-tell thing. I attended at least eight different sessions and reviewed the content for another four. None of the customers was using EJB, though Websphere has had this available since December 1998. Almost universally, these customers were using Websphere as a servlet and JSP host.

The audiences had the same questions you have right now, dear reader. Why? Why no EJB?

Remember, these customer presenters were hand-picked by IBM to describe their experiences with IBM software, particularly Websphere. The answers they gave fell into 2 categories: performance, and complexity. Some of the customers explained that they did perf evaluations of Websphere/EJB and found it wanting. One of them, a well-known online web-trading company who shall remain nameless, was quite clear and explicit about this; they continue to use FastCGI for HTML generation in favor of even Servlets or JSP, and CICS in favor of Websphere App Server.

OK. I was there too. There's no reason the customer should remain nameless since they clearly stated their name during the conference - Charles Schwab. I think you misunderstood the position - they are developing on BOTH CGI (they don't use fast CGI, by the way) and Servlets/JSP. They are even doing some EJB development. -- AnonymousDonor

[Just to address this, Schwab did describe their use of Servlets, for their Velocity application, which transmits data over the web, but is not their well-known dot-com site. Velocity uses a private address, transmits HTTP, but does not transmit HTML or XML, or anything a browser or internet presentation app might digest. It transmits a proprietary data stream between a fat client and a CICS server. The client is implemented as a Java application (not applet). The gateway just happens to be a single servlet program. The server is CICS/AIX. The Schwab rep made no other mention of JSP/Servlet, either in their schwab.com site or in the Velocity app, as far as I recall (and I was listening for this). As for doing EJB development, everyone seems to be doing EJB development. But deployments are hard to find. -- DinoChiesa ]

Others explained that it wasn't clear to them how they should apply the EJB metaphor (entities vs sessions vs servlets). [See also, HowToUseEntityBeans.]

At least one customer, another well-known financial services company, expressed plans to deploy an EJB-based app very soon. But none yet.

Full disclosure: I work for Microsoft. But you can verify this with any other attendee. -- DinoChiesa, 12 April 2000 (let the hate mail begin)


Actually, having also been at WebSphere2000, I distinctly recall several named customers (e.g. Greg Boettcher of Province of Manitoba customer talk), and unnamed customers (i.e. architectured discussed, best practices talked about, but industries, rather than customer names used with reference to EJBs -- for example, in both of Kyle Brown's sessions). Hence, I disagree that no production projects using EJBs were mentioned.

The point is not that development projects were not described; the point is that no one had deployed, not as of March 2000. No one seems to have any real experience running significant EJB-based systems.

         [For clarity, the Province of Manitoba's first EJB (both Session and Entity beans) application went
 live on or about September 6th, 2000.  -- Greg Boettcher]

Since asking the question that kicked off this discussion, I've been involved with two projects using EJBs -- one with a bank using EJBs as a generic service layer, variety of backend systems (CICS, IMS, etc.), the other for an online travel agent using SessionBeans to wrap a travel booking backend, and EntityBeans for storage/retrieval of profile information. Perhaps there's a customer story or two in here for next time.

It would be very valuable to see these projects documented in EjbCaseStudies.


I've heard that many regard EntityBeans as the weak point of WebSphere. Don't know if it's true, but even the rumor of it could explain why their customers avoid it. -- AndersBengtsson


I can't see as to why anyone would believe that. Our (WebSphere's) CMP Entity support is basically unparalleled - we support things like Entity EJB relationships and Inheritance, which go significantly beyond the EJB 1.0 and 1.1 specs. The performance is also pretty impressive - very close to raw JDBC in some cases.

-- KyleBrown


One theory could be that WebSphere was one of the earliest implementations of EJB (?). At the time when EJB servers weren't as fast as they are now and few people knew how to create efficient applications with them all EJB servers probably got that reputation... -- AndersBengtsson


IBM websphere's newsgroups have a very good active discussions on using ejb within there app server. ibm.software.websphere.application-server is the name.

--AnonymousDonor


Due to the debate over whether ejb's are a worthwhile technology, I would like to start a discussion on problems/scenarios where ejb's are a good solution or a particularly bad solution. I am kinda new to wiki, so I will attempt to create a page WhenToUseEjb and hopefully get some input there. I have no idea how to add the page to the ejb category though. -- skye


EditText of this page (last edited November 6, 2004) or FindPage with title or text search