Spring 4 RMI服务器未启动



我试图将弹簧远程远程折叠与现有的春季豆整合在一起,但似乎春季没有启动RMI服务器。我已经完成了文档中所述的必要配置,但似乎对RMI无能为力。

2016年6月23日下午6:07:59 org.springframework.context.support.classpathxmlapplicationcontext preparereFreereFresh 信息:刷新org.springframework.context.support.classpathxmlapplicationcontext@180bc464:启动日期[thu Jun Jun 23 18:07:59 IST 2016];上下文层次结构的根 2016年6月23日下午6:07:59 org.springframework.beans.factory.xml.xmlbeandefinitionreader loadBeanDefinitions 信息:从类路径资源[rmi-config.xml]加载XML bean定义

此后,Java过程死亡。我看不到与RMI有关的任何事情。

rmi-config.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
  http://www.springframework.org/schema/tx 
  http://www.springframework.org/schema/tx/spring-tx-4.0.xsd" default-lazy-init="true">

<bean id="validatorServiceBean" class="com.xyz.validator.service.impl.ValidatorServiceBean">
    <!-- any additional properties, maybe a DAO? -->
</bean>
 <!-- RMI Server Declaration -->
    <bean  class="org.springframework.remoting.rmi.RmiServiceExporter">
        <!-- serviceName represents RMI Service Name -->
        <property name="serviceName" value="ValidatorServiceBean"/>
        <!-- service represents RMI Object(RMI Service Impl) -->
        <property name="service" ref="validatorServiceBean"/>
        <!-- serviceInterface represents RMI Service Interface exposed -->
        <property name="serviceInterface" value="com.xyz.validator.service.ValidatorService"/>
        <!-- defaults to 1099 -->
        <property name="registryPort" value="1009"/>
   </bean>

</beans>

我的客户端代码:

public class RMIServerStarter {
    public static void main(String[] args) throws RemoteException {
        //RMI Server Application Context is started...
        new ClassPathXmlApplicationContext("rmi-config.xml");
        Registry registry = LocateRegistry.getRegistry("localhost", 1009);
        for (String name : registry.list()) {
            System.out.println(name);
        }
    }
}

似乎XML条目在我使用基于Java的配置时没有任何影响。

 @Bean
 public RmiServiceExporter rmiServiceExporter() {
  RmiServiceExporter exporter = new RmiServiceExporter();
  exporter.setServiceName("ValidatorService");
  exporter.setService(service);
  exporter.setServiceInterface(ValidatorService.class);
  exporter.setRegistryPort(1009);
  return exporter;
 }

相关内容

最新更新