why do I need remote interface if only web and ejb are used


General J2EE: why do I need remote interface if only web and ejb are used

  1. If I have a J2EE application with web(JSP,servlet), and EJB,do I need to build remote interface for EJB?

    I think the remote interface is nessisary only when independaten application talk to EJB.

    I think there is no reason to put JSP(servelet) and EJB on diffrent machine.

    if the J2EE application is run on a cluster enviroment,do I need remote interface.I just think in case one EJB container down,jsp could look up ejb in another node.but this sounds funny,there is few chance the EJB contain down and web contain still alive.

    is my understanding correct?

    Threaded Messages (4)

  2. Well you are right[ Go to top ]

    You only need remote interfaces if you need to talk to your EJB's remotely. If all of it (jsps, servlets, ejbs) runs inside the same container I would suggest you stick with local interfaces.

    I you need remote access to your EJB's the most common way to do it is to keep your entity beans with local interfaces but also provide remote interfaces for your session beans. The remote clients talk to the session bean which in turn handles the entity communication.

  3. Well you are right[ Go to top ]

    thank you.
    what about in the cluster enviroment.is it posible jsp access the ejbs in another node?
  4. Well you could[ Go to top ]

    Well the JSP's could access the EJB's on any specific node though it kind of defeats the point. The real point of the cluster is to have the JSPs be unaware of the server it talks to. It just knows that it can access the EJBs on a server.
  5. Well you are right[ Go to top ]

    Remeber accessing Local or Remote interfaces is not a decision the container makes - the client chooses local or remote very explicity when it does the JNDI lookup of the EJB home. In your case, you want to lookup the only the local home.

    That said, even if you lookup a remote home in a cluster, most containers will almost always choose to return the ejb home colocated in the same container. Hence implementing local interfaces is not as important as you may think.