有人经历过这个吗?

在服务器端,在我的OSGi应用程序中,我正在导出服务。这是spring文件代码:

    <!-- RMI SERVICE EXPORT -->
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    <property name="serviceName" value="IntegrationRemoteService" />
    <property name="service" ref="integrationExecutor" />
    <property name="serviceInterface" value="my.package.services.IntegrationService" />
    <property name="registryPort" value="$system{integration.port}" />
</bean>

<!-- INTEGRATION EXECUTOR -->
<bean id="integrationExecutor" class="my.package.engine.IntegrationServiceExecutor">
    <property name="integrationServiceImpl" ref="integrationEngine" />
</bean>


我的IntegrationServiceExecutor类扩展了IntegrationService接口并实现了该方法:

public class IntegrationServiceExecutor implements IntegrationService {
...
@Override
public GenericResult dispatch(int serviceCode, AdapterHeader adapterHeader,    AdapterInfo  adapterInfo) {


IntegrationService接口在另一个组件中定义,并且该相同的组件在客户端的.war中使用。在该组件中,我还实现了通过.war调用的远程请求的实现。

...
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
...

    public class GenericRmiFactory implements RemoteConnectionFactory {

private ProxyFactory proxyFactory;

public GenericRmiFactory(ServerTransport transport) throws ClassCastException, IllegalFormatException {
    RmiServerTransport rmiTransport = (RmiServerTransport) transport;

    RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();

    rmiProxyFactoryBean.setLookupStubOnStartup( false );
    rmiProxyFactoryBean.setCacheStub( false );
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure( true );
    rmiProxyFactoryBean.setServiceUrl(String.format("rmi://%s:%s/%s", rmiTransport.getHostname(), rmiTransport.getPort(), rmiTransport.getServiceName() ));
    rmiProxyFactoryBean.setServiceInterface(rmiTransport.getRemoteInterface());
    rmiProxyFactoryBean.afterPropertiesSet();

    this.proxyFactory = new ProxyFactory(rmiTransport.getRemoteInterface(), rmiProxyFactoryBean);
}

private ProxyFactory getproxyFactory() {
    return proxyFactory;
}

@Override
public Object getRemoteService() {
    return getproxyFactory().getProxy();
}
}


我以这种方式调用远程服务:

    ...
    IntegrationService integrationService = (IntegrationService) getGenericRemoteFactory().getRemoteService();
integrationService.dispatch(myInt, myAdapterHeader, myAdapterInfo);
...


最后一条语句引发异常:

Invocation of method [public abstract my.package.result.GenericResult my.package.services.IntegrationService.dispatch(int,my.package.beans.AdapterHeader,my.package.beans.AdapterInfo)] failed in RMI service [rmi://127.0.0.1:2260/IntegrationRemoteService]; nested exception is java.lang.NoSuchMethodException: $Proxy205.dispatch(int, my.package.beans.AdapterHeader, my.package.beans.AdapterInfo)


我在这里想念什么吗?
提前致谢,
卡伦

最佳答案

我以前看过您必须在接口方法中添加“ throws RemoteException”。客户端抛出NoSuchMethodException,但实际上是在抱怨缺少RemoteException。

10-06 16:04