[英]How to access EJB on remote server?
I am using a GlassFish-3.1.2 server running in my subnet (192.168.1.3:3700). 我正在使用在我的子网中运行的GlassFish-3.1.2服务器(192.168.1.3:3700)。 I already deployed an enterprise app including an EJB in which i defined a business method.
我已经部署了一个包含EJB的企业应用程序,我在其中定义了一个业务方法。 Now I want to remotely access the EJB from my java application client.
现在我想从我的Java应用程序客户端远程访问EJB。 How do i have to setup the JNDI resp.
我如何设置JNDI resp。 the InitialContext object for doing the lookup of the EJB ?
用于查找EJB的InitialContext对象? 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.
我必须运行“asadmin enabled-secure-admin”才能使GlassFish服务器在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... 当我运行这个程序时,它只是无限地等待...
Any help highly appreciated! 任何帮助高度赞赏!
I solved the problem by setting the host and port directy by System.setProperty() and using the default constructor for initializing the InitialContext(). 我通过System.setProperty()设置主机和端口并使用默认构造函数初始化InitialContext()来解决问题。 Note that the following lines should be the very first in your program / main method:
请注意,以下行应该是程序/ main方法中的第一行:
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");
}
Hope this helps ... 希望这可以帮助 ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.