如何访问远程服务器上的EJB? [英] How to access EJB on remote server?

查看:172
本文介绍了如何访问远程服务器上的EJB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用在我的子网(192.168.1.3:3700)中运行的GlassFish-3.1.2服务器。我已经部署了一个企业应用程序,其中包括一个我定义业务方法的EJB。现在我想从我的Java应用程序客户端远程访问EJB。我该如何设置JNDI和。用于查找EJB的InitialContext对象?我如何需要定义属性?顺便说一句。我必须运行asadmin enabled-secure-admin才能使GlassFish服务器在LAN上工作。也许我还需要发送我的凭据与属性?

I am using a GlassFish-3.1.2 server running in my subnet (192.168.1.3:3700). I already deployed an enterprise app including an EJB in which i defined a business method. Now I want to remotely access the EJB from my java application client. How do i have to setup the JNDI resp. the InitialContext object for doing the lookup of the EJB ? How do I need to define the properties? Btw. I had to run "asadmin enabled-secure-admin" in order to make the GlassFish server work on the LAN. Probably I also need to send my credentials with the properties ?

这是我目前的解决方案,这似乎是完全错误的:

Here's my current "solution", which seems to be completley wrong :

Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.3");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(props);

TestentityFacadeRemote tfr = (TestentityFacadeRemote)ctx.lookup("java:global/TestEE/TestEE-ejb/TestentityFacadeRemote");

当我运行这个程序时,它只是无限的等待......

When I run this programm, it just waits infinitely...

任何帮助高度赞赏!

推荐答案

我通过设置主机和端口来解决问题.setProperty()并使用默认构造函数初始化InitialContext()。请注意,以下几行应该是程序/ main方法中的第一行:

I solved the problem by setting the host and port directy by System.setProperty() and using the default constructor for initializing the InitialContext(). Note that the following lines should be the very first in your program / main method:

public static void main(String[] args) {
    System.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.3");
    System.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
    InitialContext ctx = new InitialContext();
    TestentityFacadeRemote tfr = (TestentityFacadeRemote)ctx.lookup("java:global/TestEE/TestEE-ejb/TestentityFacadeRemote!com.acme.remote.TestentityFacade");
}

希望这有助于...

这篇关于如何访问远程服务器上的EJB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆