Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i deploy Session Bean on another computer with Client JSP/Servlet

Hello Everybody i'm new in EJB3, i know how to deploy Session Bean (Stateless or stateful) on Glassfish server in one computer. My question is: how can i deploy session bean on Computer A and Deploy Servlet or JSP on Computer B? It mean Computer A have Session Bean Source and Computer B have Servlet or JSP source. if use 1 computer i can use @EJB dependency inject lookup Session Bean but on another computer how can i do it for client code? Example for 1 computer

@EJB
private StatelessRemote remote ;

double Dosomething= remote.Dosomething();

out.println(Dosomething);
like image 417
Kency Avatar asked Sep 01 '10 03:09

Kency


1 Answers

  1. Create a "client jar" with the remote interfaces, deploy in on the client

  2. Provide the app server client jar (not necessary in your scenario)

  3. Provide a jndi.properties on the classpath with the following content (assuming GlassFish to GlassFish communication):

    java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
    java.naming.factory.url.pkgs=com.sun.enterprise.naming
    java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
    org.omg.CORBA.ORBInitialHost=<hostname>
    org.omg.CORBA.ORBInitialPort=3700
    
  4. Use the mappedName attribute of the @EJB annotation to specify the global JNDI name of the target Remote EJB component (If there is no jndi-name set in sun-ejb-jar.xml - or no sun-ejb-jar.xml at all - the global jndi-name defaults to the fully qualified Remote 3.0 Business interface class name) :

    @EJB(mappedName="com.acme.app.StatelessRemote")
    private StatelessRemote remote;
    

Resources

  • GlassFish EJB FAQ
  • http://courses.coreservlets.com/Course-Materials/pdf/ejb3/EJB3-2-Session-Beans.pdf
like image 58
Pascal Thivent Avatar answered Oct 29 '22 03:10

Pascal Thivent