gpt4 book ai didi

java.lang.NoSuchMethodException : $Proxy205. 调度(int,my.package.beans.AdapterHeader,my.package.beans.AdapterInfo)

转载 作者:行者123 更新时间:2023-11-30 11:46:27 31 4
gpt4 key购买 nike

有人遇到过吗?

在服务器端,在我的 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 接口(interface)并实现了方法:

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

IntegrationService 接口(interface)在另一个组件中定义,这个相同的组件在客户端的 .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”添加到您的接口(interface)方法中。客户端抛出NoSuchMethodException,其实是在提示没有RemoteException。

关于java.lang.NoSuchMethodException : $Proxy205. 调度(int,my.package.beans.AdapterHeader,my.package.beans.AdapterInfo),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9749364/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com