Reputation: 41
Has anyone been through this?
In the server side, in my OSGi application, I'm exporting a service. Here's the spring file code:
<!-- 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>
My IntegrationServiceExecutor class extends the IntegrationService interface and implements the method:
public class IntegrationServiceExecutor implements IntegrationService {
...
@Override
public GenericResult dispatch(int serviceCode, AdapterHeader adapterHeader, AdapterInfo adapterInfo) {
The IntegrationService interface is defined in another component and this same component is used in my .war in the client side. In that component, I also have the implementation of the remote request called through my .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();
}
}
I call the remote service in this way:
...
IntegrationService integrationService = (IntegrationService) getGenericRemoteFactory().getRemoteService();
integrationService.dispatch(myInt, myAdapterHeader, myAdapterInfo);
...
This last statement throws the exception:
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)
Is there something I'm missing here? Thanks in advance, Karen
Upvotes: 2
Views: 808
Reputation: 1102
I've seen this before. You have to add 'throws RemoteException' to your interface method. The client throws a NoSuchMethodException, but it's really complaining about the lack of RemoteException.
Upvotes: 1