简体   繁体   中英

Is it possible to run RMI server in tomcat?

I have two tomact instances, running on Tomcat 7 (call it tomcat 1 , tomcat 2 ). I need to arrange distributed computation. The server tomcat 1 should invoke some method on tomcat 2 's VM.

Is it even possible to do? I know that Tomcat is a servlet container. Does it support such things?

Yes, it is possible, but you don't run RMI on Tomcat. You must run rmiregistry on server and connect to this registry form your Tomcat's. Your application should implement interface extent Remote, and its implementation like in general RMI application. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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