简体   繁体   English

使用单个RMI注册表

[英]Using single RMI Registry

I've been using RMI for a project I am currently working on and I want to bind from multiple hosts to a single RMI registry. 我一直在使用RMI进行我正在进行的项目,并且我想从多个主机绑定到单个RMI注册表。

However when I attempt to do so I get an error saying 但是,当我尝试这样做时,我得到一个错误说

java.rmi.AccessException: Registry.Registry.bind disallowed; java.rmi.AccessException:不允许Registry.Registry.bind; origin / 192.168.0.9 is non-local host origin / 192.168.0.9是非本地主机

I did so googling and it seems that RMI stops remote hosts from binding by default, what I want to know is there some way of overriding or bypassing this? 我这样做谷歌搜索,似乎RMI默认停止远程主机绑定,我想知道有什么方法可以覆盖或绕过这个?

If anyone any suggestions on how to get past this issue they would be highly appreciated, i've tried using different policy files and overriding the security manger but none seem to work. 如果有人就如何解决这个问题提出任何建议,我们将非常感激,我尝试过使用不同的策略文件并覆盖安全管理器,但似乎都没有。

There's a way to get around the limitation but it is what it is: a work-around. 有一种方法可以绕过限制,但事实就是如此:一种解决方法。 Anyway, feel free to try it out. 无论如何,请随意尝试。 It works for us. 它对我们有用。

On the host that is running the central RMI registry run a small service which will bind a remote object with just one remote method: proxyRebind. 在运行中央RMI注册表的主机上运行一个小服务,它将使用一个远程方法绑定远程对象:proxyRebind。 The implementation of this method simply binds the object that is supplied to it in the central registry (this would not fail because the registry is on the same machine as this service). 此方法的实现只是绑定在中央注册表中提供给它的对象(这不会失败,因为注册表与此服务在同一台机器上)。

All other hosts would simply lookup this remote object and invoke proxyRebind with their own remote objects. 所有其他主机只需查找此远程对象并使用自己的远程对象调用proxyRebind。

This works because look-up on remotely hosted registries is allowed. 这是有效的,因为允许在远程托管的注册表上进行查找。 Your original attempt failed because binding on remotely hosted registries is not allowed. 您的原始尝试失败,因为不允许绑定远程托管的注册表。

Let me know if you need any further clarity on this. 如果您需要进一步明确这一点,请与我们联系。

/RS / RS

2 There's a way to get around the limitation but it is what it is: a work-around. 2有一种方法可以绕过限制但它就是这样:一种解决方法。 Anyway, feel free to try it out. 无论如何,请随意尝试。 It works for us. 它对我们有用。

On the host that is running the central RMI registry run a small service which will bind a remote object with just one remote method: proxyRebind. 在运行中央RMI注册表的主机上运行一个小服务,它将使用一个远程方法绑定远程对象:proxyRebind。 The implementation of this method simply binds the object that is supplied to it in the central registry (this would not fail because the registry is on the same machine as this service). 此方法的实现只是绑定在中央注册表中提供给它的对象(这不会失败,因为注册表与此服务在同一台机器上)。

All other hosts would simply lookup this remote object and invoke proxyRebind with their own remote objects. 所有其他主机只需查找此远程对象并使用自己的远程对象调用proxyRebind。

This works because look-up on remotely hosted registries is allowed. 这是有效的,因为允许在远程托管的注册表上进行查找。 Your original attempt failed because binding on remotely hosted registries is not allowed. 您的原始尝试失败,因为不允许绑定远程托管的注册表。

Let me know if you need any further clarity on this. 如果您需要进一步明确这一点,请与我们联系。

This perfectly works. 这非常有效。 The only thing to take care is following should be always set correctly. 唯一需要注意的是应始终正确设置。 -Djava.rmi.server.hostname="LOCAL HOST IP" -Djava.rmi.server.hostname =“LOCAL HOST IP”

I may be misunderstanding your question, if so please let me know. 我可能误解了你的问题,如果有,请告诉我。

I have limited experience with Java RMI, we used it in our Design Patterns class with the Proxy Pattern. 我对Java RMI的经验有限,我们在带有代理模式的Design Patterns类中使用它。 (Textbook: Headfirst Design Patterns) (教科书:Headfirst设计模式)

We were not able to get our projects working from outside the university network, but they worked perfectly when connected directly to the network. 我们无法让我们的项目在大学网络之外工作,但是当它们直接连接到网络时,它们工作得很好。 According to our professor, it wasn't possible to use RMI in our implementation over the internet or wan. 根据我们的教授的说法,在我们通过互联网或实施的实施中使用RMI是不可能的。 A solution she suggested was that a VPN would be required. 她建议的解决方案是需要VPN。 I believe Vladimir is correct in that it has to do with it being a local naming service. 我相信弗拉基米尔是正确的,因为它与本地命名服务有关。

I may be wrong, but it looks like rmiregistry application is essentially a wrapper over local naming service. 我可能错了,但看起来rmiregistry应用程序本质上是本地命名服务的包装器。 Which means there is no way to make it point to remote objects. 这意味着无法使其指向远程对象。

What you need is a Naming implementation, and clustered at this. 你需要的是一个命名实现,并在此集群。 Consider to move into J2EE AS clustering solution. 考虑进入J2EE AS集群解决方案。 JNDI tree is shared within the cluster. JNDI树在集群中共享。

Thanks for everyones answers the solution I came up with in the end was to use the Cajo Framework this gives a very flexible system for distribution and it allowed for me to handle the registry as I saw fit. 感谢大家回答我最终提出的解决方案是使用Cajo框架,它提供了一个非常灵活的分发系统,它允许我按照我认为合适的方式处理注册表。 It can also work behind NATs, firewalls, and HTTP proxies, which is very useful. 它也可以在NAT,防火墙和HTTP代理之后工作,这非常有用。

I believe that the method of proxying suggested by rndm.buoy will work in some cases but its may be troublesome on some system. 我相信rndm.buoy建议的代理方法在某些情况下会起作用,但在某些系统上可能会很麻烦。 RMI seems to have some issues with associating to the wrong Network Interface I particularly had this issue when running on Debian based Linux distributions. RMI似乎有一些与错误的网络接口相关联的问题我在基于Debian的Linux发行版上运行时特别容易出现这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM