春季 RMI - 查找 RMI 存根失败



我正在使用Spring 3.2,在尝试基于"远程"RMI服务创建Bean定义时出现以下错误。客户端和服务器已在同一主机上实现。

org.springframework.remoting.RemoteLookupFailureException: 
Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.EOFException. 

我正在尝试部署到 Glassfish 3.1.2。所涉及的代码如下所示-

弹簧奴仆.xml

<!-- Remoting Config (server) -->
<bean id="testRmiService" class="com.test.backend.rmi.TestRmiServiceImpl" />
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    <property name="serviceName" value="CountryService"/>
    <property name="service" ref="testRmiService"/>
    <property name="serviceInterface" value="com.test.backend.rmi.TestRmiService"/>
    <property name="registryPort" value="1099"/>
</bean>

<!-- Remoting Config (client) -->
<bean id="helloService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
    <property name="serviceUrl" value="rmi://localhost:1099/CountryService"/>
    <property name="serviceInterface" value="com.test.backend.rmi.TestRmiService"/>
</bean>
package com.test.backend.rmi;
public interface TestRmiService {
public String doSomething();
}
package com.test.backend.rmi;
public class TestRmiServiceImpl implements TestRmiService {
    public String doSomething() {
        return "hello";
    } 
}

我使用 netstat 进行了检查,该服务似乎在端口 1099 上运行。任何想法都值得赞赏 - 提前感谢。

问题可能是Glassfish不喜欢通过"后门"打开的RMI连接。我宁愿建议通过HTTP调用程序实现远程处理:http://www.javatpoint.com/spring-remoting-by-http-invoker-example

最新更新