java.rmi.server.ExportException: 远程对象实现了非法的远程接口

huangapple go评论71阅读模式
英文:

java.rmi.server.ExportException: remote object implements illegal remote interface

问题

获取此错误:

1) 注入构造函数时出错,java.rmi.server.ExportException: 远程对象实现了非法远程接口;嵌套异常是:
	java.lang.IllegalArgumentException: 遇到非法远程方法:public abstract java.util.List com.mycompany.repository.CustomCodeRepository.getCustomCodeEntity(java.lang.String,java.lang.String,java.lang.String)
  在 com.mycompany.repository.impl.CustomCodeRepositoryImpl.<init> (CustomCodeRepositoryImpl.java:63)
  定位位置:com.mycompany.repository.impl.CustomCodeRepositoryImpl
  在 com.mycompany.guice.GuiceConfigModule.configure (GuiceConfigModule.java:79)
  定位位置:com.mycompany.repository.CustomCodeRepository
    位于字段:com.mycompany.resource.ServerResource.customCodeRepository(ServerResource.java:53)
  定位位置:com.mycompany.resource.ServerResource

对于此代码:

@Override
protected void configure() {
  
  bind(EntityRepository.class).to(EntityRepositoryImpl.class).in(Scopes.SINGLETON);  
  bind(CustomCodeRepository.class).to(CustomCodeRepositoryImpl.class).in(Scopes.SINGLETON);
}
public class CustomCodeRepositoryImpl extends UnicastRemoteObject
        implements CustomCodeRepository {

  @Inject
  @Named("xodusRoot")
  String xodusRoot;

  @Inject
  @Named("masterStore")
  String masterStore;

  @Inject 
  EntityRepository entityRepository;

  public CustomCodeRepositoryImpl() throws RemoteException {
  }

  @Override
  public String createCustomCode(String appId, String namespace, String customCodeName, String description, Long timeout, InputStream jar) {
  }
  @Override
  public List<Map<String, Comparable>> getCustomCodeEntity(String appId, String namespace, String customCodeName) {
    return entityRepository.getEntity(
            appId,
            namespace,
            Constants.ENTITYSTORE_CUSTOMCODE,
            Constants.CUSTOMCODE_NAME,
            customCodeName,
            new ArrayList<>());
  }
英文:

Getting this error:

1) Error injecting constructor, java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is: 
	java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.List com.mycompany.repository.CustomCodeRepository.getCustomCodeEntity(java.lang.String,java.lang.String,java.lang.String)
  at com.mycompany.repository.impl.CustomCodeRepositoryImpl.&lt;init&gt;(CustomCodeRepositoryImpl.java:63)
  while locating com.mycompany.repository.impl.CustomCodeRepositoryImpl
  at com.mycompany.guice.GuiceConfigModule.configure(GuiceConfigModule.java:79)
  while locating com.mycompany.repository.CustomCodeRepository
    for field at com.mycompany.resource.ServerResource.customCodeRepository(ServerResource.java:53)
  while locating com.mycompany.resource.ServerResource

For this code:

@Override
protected void configure() {
  
  bind(EntityRepository.class).to(EntityRepositoryImpl.class).in(Scopes.SINGLETON);  
  bind(CustomCodeRepository.class).to(CustomCodeRepositoryImpl.class).in(Scopes.SINGLETON);
}
public class CustomCodeRepositoryImpl extends UnicastRemoteObject
        implements CustomCodeRepository {

  @Inject
  @Named(&quot;xodusRoot&quot;)
  String xodusRoot;

  @Inject
  @Named(&quot;masterStore&quot;)
  String masterStore;

  @Inject 
  EntityRepository entityRepository;

  public CustomCodeRepositoryImpl() throws RemoteException {
  }

  @Override
  public String createCustomCode(String appId, String namespace, String customCodeName, String description, Long timeout, InputStream jar) {
  }
  @Override
  public List&lt;Map&lt;String, Comparable&gt;&gt; getCustomCodeEntity(String appId, String namespace, String customCodeName) {
    return entityRepository.getEntity(
            appId,
            namespace,
            Constants.ENTITYSTORE_CUSTOMCODE,
            Constants.CUSTOMCODE_NAME,
            customCodeName,
            new ArrayList&lt;&gt;());
  }

答案1

得分: 2

guice在其异常中提到,这是一个嵌套异常。内部异常是:

java.lang.IllegalArgumentException: 遇到非法的远程方法: public abstract java.util.List com.mycompany.repository.CustomCodeRepository.getCustomCodeEntity(java.lang.String,java.lang.String,java.lang.String)

我猜测您正在覆盖java.rmi.Remote。如果是这样,那么我会引用来自Java中的非法远程方法的内容:

RMI远程接口上的所有方法都必须在其throws子句中声明RemoteException。

这意味着您需要将throws RemoteException添加到扩展Remote的接口中的所有方法的声明中,这可能是CustomCodeRepository

英文:

As guice mention in its exception, it is a nested exception. The inner exception is:

java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.List com.mycompany.repository.CustomCodeRepository.getCustomCodeEntity(java.lang.String,java.lang.String,java.lang.String)

I'd guess that you are overriding java.rmi.Remote. If that is the case, so I'll quote from Illegal remote method in java:

> All of the methods on a RMI Remote interface must declare RemoteException in their throws clause.

That means that you need to add throws RemoteException to the declaration of all methods in the interface that is extending Remote. That is probably CustomCodeRepository.

huangapple
  • 本文由 发表于 2020年9月22日 03:38:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63998930.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定