LAN上的CORBA查找挂起

时间:2014-11-22 12:09:50

标签: java-ee glassfish client-server corba system-administration

是否需要任何特定的Glassfish配置才能允许通过LAN进行远程CORBA查找?或者,或许,路由器防火墙是否需要配置?

我如何troubleshoot此连接?

CORBA lookup client只是挂起:

BUILD SUCCESSFUL
Total time: 3 seconds
Nov 22, 2014 3:45:26 AM aggregatorclient.AggregatorClient remoteEJB
WARNING: {org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, Context.SECURITY_CREDENTIALS=pass123, org.omg.CORBA.ORBInitialHost=192.168.0.119, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, Context.SECURITY_PRINCIPAL=user1}

当从localhost(即从localhost连接到localhost)运行时,同一台计算机上的所有内容都可以正常运行。

jndi.properties中的CORBA连接查找参数:

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
Context.SECURITY_PRINCIPAL=user1
Context.SECURITY_CREDENTIALS=pass123
org.omg.CORBA.ORBInitialHost=192.168.0.119
org.omg.CORBA.ORBInitialPort=3700

连接客户端代码:

package aggregatorclient;

import dur.ejb.AnswerSessionBeanRemote;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class AggregatorClient {

    private static final Logger log = Logger.getLogger(AggregatorClient.class.getName());

    public static void main(String[] args) {
        try {
            new AggregatorClient().remoteEJB();
        } catch (NamingException ex) {
            Logger.getLogger(AggregatorClient.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void remoteEJB() throws NamingException {
        Context ctx = new InitialContext();
        log.warning(ctx.getEnvironment().toString());
        Object obj = ctx.lookup("dur.ejb.AnswerSessionBeanRemote");
        AnswerSessionBeanRemote asbr = (AnswerSessionBeanRemote) obj;
        log.info("answer\t" + asbr.lifeTheUniverseAndEverything());
    }

}

使用Glassfish appclient执行client

1 个答案:

答案 0 :(得分:1)

与远程主机上运行的独立ejb客户端具有相同的“永久挂起”查找行为。事实证明,这与服务器主机将其自己的主机名解析为自己的非环回地址的能力有关。我通过添加/修复/etc/hosts中的条目来解决它:

10.0.10.102    my-server-hostname

我检查过服务器实际上可以使用hostname -i解析正确的IP地址:

$ hostname -i
10.0.10.102

重新启动GlassFish后,远程查找和调用EJB就像一个魅力!

说明

我在嗅探客户端和服务器之间的流量后找到了这个解决方案。基础协议是GIOP(从未听说过)。

执行远程查找时,我的客户端的请求 实际上能够访问GlassFish。但是服务器回复了一个误导性的“位置转发”响应,指示127.0.1.1IIOP:Profile_host127.0.1.1是我修复/etc/hosts之前我的服务器主机名解析的环回IP地址。