org.omg.CORBA.Object上的错误objRef = orb.resolve_initial_references(" NameService");

时间:2015-11-02 18:04:16

标签: java eclipse corba

当我运行我的简单CORBA服务器(我在本教程之后构建)时,我得到了这个奇怪的错误

这是我的代码:

import org.omg.CORBA.ORB;
import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.CosNaming.NamingContextPackage.CannotProceed;
import org.omg.CosNaming.NamingContextPackage.NotFound;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongPolicy;

import HotelServer.Hotel;
import HotelServer.HotelHelper;
import HotelServer.HotelImpl;


public class StartServers {

    public static void main(String[] args) throws AdapterInactive, InvalidName, ServantNotActive, WrongPolicy, NotFound, CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
          // create and initialize the ORB //// get reference to rootpoa & activate the POAManager
        ORB orb = ORB.init(args, null);
        POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        rootpoa.the_POAManager().activate();

        HotelImpl hotel = new HotelImpl();
        hotel.setOrb(orb);

        // get object reference from the servant
        org.omg.CORBA.Object ref = rootpoa.servant_to_reference(hotel);
        Hotel hotelref = HotelHelper.narrow(ref);

        org.omg.CORBA.Object objRef =  orb.resolve_initial_references("NameService");
        NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

        NameComponent path[] = ncRef.to_name( "hotel1" );
        ncRef.rebind(path, hotelref);

        orb.run();

        System.out.println("ORB Server is running...");
    }

}

此行发生错误:org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

这是完整的错误:

com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 1050"
org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknown Source)
    at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(Unknown Source)
    at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(Unknown Source)
    at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source)
    at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source)
    at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source)
    at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(Unknown Source)
    at StartServers.main(StartServers.java:34)
Caused by: java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect0(Native Method)
    at sun.nio.ch.Net.connect(Unknown Source)
    at sun.nio.ch.Net.connect(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
    at java.nio.channels.SocketChannel.open(Unknown Source)
    at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(Unknown Source)
    ... 12 more

1 个答案:

答案 0 :(得分:1)

User Reimus不久之前发布了一个答案,我报告说它没有工作。事实证明它正在闪烁一个超级快速错误消息,该端口正在使用中。当我解决这个问题时,他的原始解决方案有效。 Reimus,请转发你的答案,以便我接受。在那之前,这是他原来的答案:

运行

start tnameserv -ORBInitialPort 1051

确保端口1051尚未用于其他内容。你应该看到

TNameserv