2
有沒有人通過這個?
在服務器端,在我的OSGi應用程序中,我正在導出服務。這裏的春天文件代碼:
<!-- 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)
有什麼我在這裏失蹤? 在此先感謝, 凱倫
lifesaver,謝謝! – jasonoriordan 2016-04-12 09:38:26