org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService") 上的错误;
Posted
技术标签:
【中文标题】org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService") 上的错误;【英文标题】:Error on org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); 【发布时间】:2015-11-02 18:04:16 【问题描述】:我在运行简单的 CORBA 服务器时遇到了这个奇怪的错误(我按照本教程构建的 0
这是我的代码:
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】:User Reimus 不久前发布了一个答案,我报告说它不起作用。原来它正在闪烁一个超级快速的错误消息,表明该端口正在使用中。当我解决这个问题时,他最初的解决方案奏效了。 Reimus,请重新发布您的答案,以便我接受。在那之前,这是他的原始答案:
运行
start tnameserv -ORBInitialPort 1051
确保端口1051
尚未用于其他用途。你应该看到
【讨论】:
以上是关于org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService") 上的错误;的主要内容,如果未能解决你的问题,请参考以下文章
org.omg.CORBA.OBJECT_NOT_EXIST 尝试获取根命名上下文“NameService”时
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService") 上的错误;