String[] orbargs= {};
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(orbargs, null);
org.omg.CORBA.Object cobj = orb.string_to_object("corbaloc:iiop:10.1.1.200:6969/OurServiceHelper");
_OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj); // Get's stuck
cpsh.ourMethod();
That narrow just hangs.
狭窄的挂起。
My service is setup to run on a static port. And we know it works since we usually look it up through the NamingService.
我的服务是运行在一个静态端口设置。我们知道它是由于我们通常通过NamingService查。
What am I doing wrong?
我做错了什么?
3 个解决方案
#1
1
If you're using the NamingService, you should actually be using a corbaname url instead of a corbaloc url. The below will work if your naming service is on port 6969. If "OurServiceHelper" is on 6969 but the NamingService is on a different port, you need to specify the port of the naming service in the url below instead of 6969. The port of the server object is embedded in the ior returned by the NamingService so that's why it doesn't need to be specified.
如果您使用的是NamingService,那么实际上应该使用corbaname url而不是corbaloc url。如果您的命名服务位于端口6969上,下面将工作。如果“OurServiceHelper”在6969上,但是NamingService在另一个端口上,您需要在下面的url中指定命名服务的端口,而不是6969。服务器对象的端口被嵌入到NamingService返回的ior中,因此不需要指定它。
"corbaname:10.1.1.200:6969#OurServiceHelper"
Re: Comment: First a note about IORs and serving up objects. If you want your served objects to be persistent across process restarts, you have to set the PERSISTENT
lifetime policy on the POA that contains the objects. Also, the IOR embeds the ip and port of the server, so if you want to generate IORs that remain consistent across restarts you have to use a static IP and port number as well as using the persistent lifetime policy.
评论:首先是关于“地位”和“服务对象”的注释。如果希望服务对象在进程重新启动时是持久的,则必须在包含对象的POA上设置PERSISTENTlifetime策略。此外,IOR嵌入了服务器的ip和端口,因此,如果您想要在重新启动时生成始终一致的IOR,您就必须使用静态ip和端口号以及使用持久生存期策略。
The name service makes things easier by allowing you not to have to worry about a lot of this stuff. As long as the name service is reachable at a known location, all of your server objects can just register themselves with the name service when they are instantiated and clients can then access them without having to know where they're located.
名称服务使事情变得更容易,因为它允许您不必担心很多此类内容。只要名称服务在已知位置上可到达,所有服务器对象就可以在实例化时注册名称服务,然后客户端可以访问它们,而不必知道它们位于何处。
If you're determined not to use the name service you're code will have to change somewhat. If you use the corbaloc
url then you are using the Interoperable Naming Service (INS). See: http://java.sun.com/j2se/1.4.2/docs/guide/idl/INStutorial.html. Using the INS, you need to use the functionality of the NamingContextExt
object. Specifically, to resolve the corabloc url that you construct you should call the NamingContextExt::resolve_str
function and pass in the url.
如果您决定不使用您的代码的名称服务,那么您必须做一些更改。如果您使用corbalocurl,那么您将使用可互操作的命名服务(INS)。参见:http://java.sun.com/j2se/1.4.2/docs/guide/idl/INStutorial.html。使用INS,您需要使用namingcontext文本对象的功能。具体地说,要解析构造的corabloc url,应该调用namingcontext文本::resolve_strfunction并传入url。
#2
0
The key part of the corbaloc URL (string after the slash), could possibly be incorrect or not registered correctly, and the serverside orb isn't able to map the key to the object reference.
corbaloc URL的关键部分(斜线后的字符串)可能不正确或注册不正确,服务器端orb不能将键映射到对象引用。
How are you running the server?
如何运行服务器?
This should work:
这应该工作:
<server> -ORBInitRef OurServiceHelper="file://server.ior"
So when the corbaloc request comes in the orb should be able to match the key to the ior and return you the ior. Different ORB's have different ways of doing this for registering an initial reference, TAO have a propriety interface called IORTable for example.
因此,当corbaloc请求到达orb时,应该能够匹配ior的键并返回ior。不同的ORB有不同的方法来注册一个初始的引用,TAO有一个称为IORTable的适当接口。
#3
0
The corbaloc has no type info in it, so the ORB is checking the type you're narrowing to by making a remote call (_is_a). Try using an unchecked narrow, which won't call _is_a:
corbaloc没有类型信息,所以ORB通过远程调用(_is_a)检查您正在缩小的类型。尝试使用一个未选中的窄条,它不会调用_is_a:
_OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj);
It's odd that the _is_a call doesn't return for you. My guess is that the unchecked_narrow will work work (you'll get a non-null result), but the object reference won't work.
奇怪的是,_is_a调用没有返回给你。我的猜测是unchecked_narrow可以工作(您将得到一个非空结果),但是对象引用不能工作。
#1
1
If you're using the NamingService, you should actually be using a corbaname url instead of a corbaloc url. The below will work if your naming service is on port 6969. If "OurServiceHelper" is on 6969 but the NamingService is on a different port, you need to specify the port of the naming service in the url below instead of 6969. The port of the server object is embedded in the ior returned by the NamingService so that's why it doesn't need to be specified.
如果您使用的是NamingService,那么实际上应该使用corbaname url而不是corbaloc url。如果您的命名服务位于端口6969上,下面将工作。如果“OurServiceHelper”在6969上,但是NamingService在另一个端口上,您需要在下面的url中指定命名服务的端口,而不是6969。服务器对象的端口被嵌入到NamingService返回的ior中,因此不需要指定它。
"corbaname:10.1.1.200:6969#OurServiceHelper"
Re: Comment: First a note about IORs and serving up objects. If you want your served objects to be persistent across process restarts, you have to set the PERSISTENT
lifetime policy on the POA that contains the objects. Also, the IOR embeds the ip and port of the server, so if you want to generate IORs that remain consistent across restarts you have to use a static IP and port number as well as using the persistent lifetime policy.
评论:首先是关于“地位”和“服务对象”的注释。如果希望服务对象在进程重新启动时是持久的,则必须在包含对象的POA上设置PERSISTENTlifetime策略。此外,IOR嵌入了服务器的ip和端口,因此,如果您想要在重新启动时生成始终一致的IOR,您就必须使用静态ip和端口号以及使用持久生存期策略。
The name service makes things easier by allowing you not to have to worry about a lot of this stuff. As long as the name service is reachable at a known location, all of your server objects can just register themselves with the name service when they are instantiated and clients can then access them without having to know where they're located.
名称服务使事情变得更容易,因为它允许您不必担心很多此类内容。只要名称服务在已知位置上可到达,所有服务器对象就可以在实例化时注册名称服务,然后客户端可以访问它们,而不必知道它们位于何处。
If you're determined not to use the name service you're code will have to change somewhat. If you use the corbaloc
url then you are using the Interoperable Naming Service (INS). See: http://java.sun.com/j2se/1.4.2/docs/guide/idl/INStutorial.html. Using the INS, you need to use the functionality of the NamingContextExt
object. Specifically, to resolve the corabloc url that you construct you should call the NamingContextExt::resolve_str
function and pass in the url.
如果您决定不使用您的代码的名称服务,那么您必须做一些更改。如果您使用corbalocurl,那么您将使用可互操作的命名服务(INS)。参见:http://java.sun.com/j2se/1.4.2/docs/guide/idl/INStutorial.html。使用INS,您需要使用namingcontext文本对象的功能。具体地说,要解析构造的corabloc url,应该调用namingcontext文本::resolve_strfunction并传入url。
#2
0
The key part of the corbaloc URL (string after the slash), could possibly be incorrect or not registered correctly, and the serverside orb isn't able to map the key to the object reference.
corbaloc URL的关键部分(斜线后的字符串)可能不正确或注册不正确,服务器端orb不能将键映射到对象引用。
How are you running the server?
如何运行服务器?
This should work:
这应该工作:
<server> -ORBInitRef OurServiceHelper="file://server.ior"
So when the corbaloc request comes in the orb should be able to match the key to the ior and return you the ior. Different ORB's have different ways of doing this for registering an initial reference, TAO have a propriety interface called IORTable for example.
因此,当corbaloc请求到达orb时,应该能够匹配ior的键并返回ior。不同的ORB有不同的方法来注册一个初始的引用,TAO有一个称为IORTable的适当接口。
#3
0
The corbaloc has no type info in it, so the ORB is checking the type you're narrowing to by making a remote call (_is_a). Try using an unchecked narrow, which won't call _is_a:
corbaloc没有类型信息,所以ORB通过远程调用(_is_a)检查您正在缩小的类型。尝试使用一个未选中的窄条,它不会调用_is_a:
_OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj);
It's odd that the _is_a call doesn't return for you. My guess is that the unchecked_narrow will work work (you'll get a non-null result), but the object reference won't work.
奇怪的是,_is_a调用没有返回给你。我的猜测是unchecked_narrow可以工作(您将得到一个非空结果),但是对象引用不能工作。