【发布时间】:2013-06-14 07:30:30
【问题描述】:
我有一个在 Tomcat 中运行的 Spring webapp。
此应用还需要公开服务以通过 RMI 进行远程访问。我正在使用 Spring 的 RmiServiceExporter 来执行此操作:
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="${server.rmi.remoteServiceName}"/>
<property name="service" ref="remoteFacade"/>
<property name="serviceInterface" value="my.ServiceInterface"/>
<!-- defaults to 1099 -->
<property name="registryPort" value="${server.rmi.registryPort}"/>
</bean>
它运行良好,但是当我关闭 Tomcat 时,它挂起,我必须将其终止,然后手动终止它为 RMI 注册表创建的 Java 进程。这似乎是因为我应该在创建RmiServiceExporter 的上下文上明确关闭(即调用close() 方法),在这种情况下是我的应用程序上下文(而不是Web 上下文)。 (来源:https://issues.springsource.org/browse/SPR-5601)
如何在 webapp 中实现这一点(在应用程序停止时调用上下文上的 close() 方法),其中上下文由 ServletContextListener (org.springframework.web.context.ContextLoaderListener) 创建?
编辑:我的问题实际上被误导了。上下文实际上已经被关闭,RmiServiceExporter 的 destroy() 方法也是如此。问题(tomcat 无法正常关闭)似乎来自其他问题。请花时间回答这个问题的用户原谅我匆忙发布它。
【问题讨论】:
-
您能否分享一下导致最初问题的原因。(tomcat 无法正常关闭)及其解决方案。 (目前我也面临类似的问题)
-
@Akash :对不起,那是很久以前的事了,我不记得了。但与 RMI 无关。
标签: java spring spring-mvc rmi