Technical issue on EJB

Discussions

EJB design: Technical issue on EJB

  1. Technical issue on EJB (2 messages)

    I have some findings about technical aspects of EJB, Can someone help me to adjust the problems?

    1. No concurrent access to Stateful Session Beans

    The EJB spec doesn't allow for concurrent access to a Stateful Session Bean(SFSB). The spec disallows creation of threads from within an EJB, and also explicitly requires the container to throw an exception if multiple callers
    invoke it concurrently. This requirment really limits the practical usage of Stateful Session beans. For example, a SFSB it won't be able to handle the very common scenario of multiple requests coming in concurrently from a single browser (a single web page may imply many concurrent requests); you cannot use the state in the SFSB to conditionally redirect image requests.

    To solve this, you may enforce request serialization in the servlet; but this becomes virtually impossible if the servlets handling incoming request are executing on different machines.

    2. No support for Threads in JSP, Servlet, or EJB

    Also, a little known fact regarding thread support in JSP and Servlet (these are specified, along with EJB, in the mother-of-all enterprise Java standards, the J2EE). Quote from the Servlet 2.2 spec:

    A Servlet Container may place security restrictions on the environment that a servlet executes in. In a Java 2 Platform Standard Edition 1.2 (J2SE) or Java 2 Platform Enterprise Edition 1.2 (J2EE)environment, these restrictions
    should be placed using the permission architecture defined by Java 2 Platform. For example, high end application servers may limit certain action, such as the creation of a Thread object, (emphasis mine) to insure that other components of the container are not negatively impacted.

    One developer reported that the J2EE ref implementation from Sun does not permit thread creation in JSP or Servlets. The code will generates thread exceptions. With BEA WebLogic it works, but is supposedly "unsupported."
    With IBM WebSphere, it works.

    EJB v2.0 does not add thread support.

    3. No Failover of Session Beans

    Excerpt from BEA's online WebLogic documentation,
    http://www.weblogic.com/docs51/cluster/overview.html#998260
    <http://www.weblogic.com/docs51/cluster/overview.html#998260>, regarding Stateful EJBs (SFSB's):

    When a home creates a stateful bean, it returns a stub that is pinned to the server hosting the home. Because this bean holds state on behalf of the client, all calls must be routed to the single instance. So in the case of a
    stateful bean, load-balancing and fail-over only occur during calls to the home. Once the stateful bean has been created, all calls for it must go to the same server. (emphasis mine) If a failure occurs, the client code must
    catch the remote exception and retry by creating a new instance using the clustered home.

    There is no support in the EJB specification for persistence or failover of stateful session beans. Nor is there any support for HTTP Session persistence in the JSP or Servlet specifications. Any persistence or failover is a "value-add" which his provided differently by each vendor. BEA does not yet provide it. IBM provides it, but it implies a proprietary API, and quality and scalability are suspect.

    Threaded Messages (2)

  2. Technical issue on EJB[ Go to top ]

    Hi: Carson. As we all know that there is not a silver bullet that solves all the problem, so EJB is not the answer of all software development. It is a nothing more or less than a frame work to develop distributed server side business objects. It definitely has it pros and cons, and writing a multi threaded application is not a good choice for EJB frame work. But so far it has been very successful in e-commerce application development. You are right that we can not call an EJB asynchronously in EJB1.0 or 1.1(even though we can use a JMS and can call an EJB asynchronously), please check the EJB spec2.0 and see the concept behind message driven bean that will allow you to call EJB(only message driven bean) asynchronously. Again not a single language, OS or frame work can solve all the software engineering problem in this world, we gotta choose one that is appropriate for the requirement.

    Thanks,
    Rashid
  3. Technical issue on EJB[ Go to top ]

    1) Concurrent access is allowed in Servlets however. Use a servlet as a controller which allows concurrent access and itself creates stateless beans. State in the servlet can be maintained in the HttpSession.

    2) The use of a JMS messaging substrate can easily "mimic" threads and provides a much better quality of service

    3) Sybase EAServer provides failover for Stateful session beans as well as failover of HttpSessions for JSP/Servlet and requires no proprietary code or API's

    Dave Wolf
    Internet Applications Division
    Sybase