JSP using EJB


Web tier: servlets, JSP, Web frameworks: JSP using EJB

  1. JSP using EJB (1 messages)


    I have implemented a JSP page that uses a Session-EJB. I have done this by writing a JavaBean to connect to the EJB and hold the remote references to it at session scope.


    <jsp:useBean id="ejbBean" class="..." scope="session" />
    //At the place where I need the EJB
    <% remoteRef = ejbBean.getRemoteRef(); %>

    The bean "ejbBean" does all the stuff (JNDI Lookup, ejb.create(), etc) for me. It implements the HttpSessionBindingListener to hold the remote reference for the whole session:

    public class ejbBean implements HttpSessionBindingListener {
    public void valueBound() {

    public void valueUnbound() {

    private void createBeans() {
      // JNDI-Stuff
      Context ic = new InitialContext();
      // Create EJB
      home = ic.lookup("ejb");
      remoteRef = home.create();

    private void removeBeans() {

    (This example is simplified)

    We experience some problems with that: The server gets an OutOfMemory-Exception and crashes (Oracle iAS), but only when the EJBs are called by the JSP. (Multithreading problem?)

    Does anyone have similar problems when calling EJBs from JSPs?

    BTW: Is this the correct design approach ?

    Threaded Messages (1)

  2. JSP using EJB[ Go to top ]

    the only thing I see is that remoteRef gets over written when you call createBeans, hence you are not closing the ones that are already created.
    But the pattern looks right to me, and you should not run out of memory. that sounds like a problem in the server itself
    Good luck, maybe you should try to contact Oracle for this