Hello Everybody i'm new in EJB3, i know how to deploy Session Bean 开发者_StackOverflow(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);
Create a "client jar" with the remote interfaces, deploy in on the client
Provide the app server client jar (not necessary in your scenario)
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
Use the
mappedName
attribute of the@EJB
annotation to specify the global JNDI name of the target Remote EJB component (If there is nojndi-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
精彩评论