问题描述
你好每个人都是EJB3的新人,我知道如何在一台电脑上的Glassfish服务器上部署Session Bean(无状态或有状态)。我的问题是:如何在计算机A上部署会话bean并在计算机B上部署Servlet或JSP?这意味着
计算机A有会话Bean源
和计算机B具有Servlet或JSP源。
如果使用1台电脑我可以使用@EJB依赖注入查找会话Bean
但在另一台计算机上如何才能为客户端代码?
1台计算机的示例
@EJB
private StatelessRemote remote;
double Dosomething = remote.Dosomething();
out.println(Dosomething);
-
创建一个客户端jar与远程接口,部署在客户端
-
提供应用服务器客户端jar(在您的方案中不需要)
-
在类路径中提供一个
jndi.properties
,其中包含以下内容(假设GlassFish到GlassFish通信):java.naming.factory.initial = com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url。 gp =主机名>
org.omg.CORBA.ORBInitialPort = 3700
-
使用
mappedName
属性的@EJB
注释,以指定目标远程EJB组件的全局JNDI名称(如果没有jndi-name
在sun-ejb-jar.xml中设置 - 或者没有sun-ejb-jar.xml - 全局jndi-name默认为完全限定的Remote 3.0 Business界面类名称):@EJB(mappedName =com.acme.app.StatelessRemote)
private StatelessRemote remote;
资源
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 meanComputer A have Session Bean Sourceand Computer B have Servlet or JSP source.if use 1 computer i can use @EJB dependency inject lookup Session Beanbut 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
这篇关于如何使用Client JSP / Servlet在另一台计算机上部署Session Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!