java.lang.NoSuchMethodException: $ Proxy205.dispatch (int, my.package.beans.AdapterHeader, my.package.beans.AdapterInfo) - PullRequest
2 голосов
/ 17 марта 2012

Кто-нибудь прошел через это?

На стороне сервера, в моем приложении 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)

Есть что-то, что я здесь упускаю? Заранее спасибо, Karen

1 Ответ

1 голос
/ 24 марта 2012

Я видел это раньше.Вы должны добавить «throws RemoteException» в ваш метод интерфейса.Клиент выдает NoSuchMethodException, но он действительно жалуется на отсутствие RemoteException.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...