Search code examples
javajakarta-eenetbeansejb

Netbeans Remote In Project (EJB)


This is so confusing, when I make a new Session Bean in Netbeans, it has an option for making local interface, and a remote. If I choose the remote however, a list comes up with existing Java SE, and ME projects. If I choose any of them (by the way one of them I intended to use as a GUI client for the beans later). It makes the session beans in my Enterprise Application, but it adds the remote class in the Java SE project. I don't get it what is this about?

 My Netbeans Project Tree

enter image description here

enter image description here


Solution

  • If you create an stateless EJB sesion bean, it can implement a local and/or a remote interface.

    In your case I suggest using the remote interface, because one of your clients will be remote: A command-line stand-alone application is typically not run on the application server host (in contrast to a servlet which normally resides in the same JVM).

    Try to design the remote interface in a way that one user interaction results in one call to the EJB layer. If your stand-alone application runs fast enough, the servlet is probably fast enough as well. If you do it the other way round, you possibly will find out that the interface design which works for a servlet is not suitable for remote access.

    There are some semantic and technical differences between the local and the remote interface: Using the first means that the interface is designed to be used only from localhost (so many calls do not really affect performance). Local beans only live in one JVM. It affects the behaviour regarding call by value/reference (see Why do we need separate Remote and Local interfaces for EJB 3.0 session beans).


    Regarding the NetBeans screenshots:

    • The (remote) client has the remote interface in its scope. That's OK, as it does not need to see anything else.

    • On the server/EJB side, there is everything else: The EJB, and the local interface. The only thing which seems to be missing is the remote interace, as the EJB implements it as well. There is possibly some NetBeans IDE magic behind it, but the server side needs the remote interface as well.