简体   繁体   English

是否可以在tomcat中运行RMI服务器?

[英]Is it possible to run RMI server in tomcat?

I have two tomact instances, running on Tomcat 7 (call it tomcat 1 , tomcat 2 ). 我有两个在Tomcat 7上运行的tomact实例(称为tomcat 1tomcat 2 )。 I need to arrange distributed computation. 我需要安排分布式计算。 The server tomcat 1 should invoke some method on tomcat 2 's VM. 服务器tomcat 1应该在tomcat 2的VM上调用某些方法。

Is it even possible to do? 有可能做吗? I know that Tomcat is a servlet container. 我知道Tomcat是一个servlet容器。 Does it support such things? 它支持这样的事情吗?

Yes, it is possible, but you don't run RMI on Tomcat. 是的,可以,但是您不能在Tomcat上运行RMI。 You must run rmiregistry on server and connect to this registry form your Tomcat's. 您必须在服务器上运行rmiregistry并从Tomcat的注册表连接到该注册表。 Your application should implement interface extent Remote, and its implementation like in general RMI application. 您的应用程序应实现接口范围Remote,并且其实现应与一般RMI应用程序一样。 It could be a little hard, because you must register your service twice once for tomcat 1, and second for tomcat 2, it could be done via configuration or hard coded. 这可能会有点困难,因为您必须为tomcat 1一次注册一次服务,而对于tomcat 2必须第二次注册服务,这可以通过配置或硬编码来完成。

Maybe you should consider provide your RMI Server as java application, and invoke there method from Tomcat or read about JMS, it is more common solution today than RMI. 也许您应该考虑将RMI Server作为Java应用程序提供,并从Tomcat调用该方法或阅读有关JMS的知识,今天它是比RMI更常见的解决方案。

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

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