英文:
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.<init>(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("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<>());
}
答案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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论