java.rmi.server.ExportException: 远程对象实现非法远程接口
java.rmi.server.ExportException: remote object implements illegal remote interface
出现此错误:
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
对于此代码:
@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<>());
}
正如 guice 在其异常中提到的那样,它是一个嵌套异常。内部异常是:
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)
我猜你正在覆盖 java.rmi.Remote
。如果是这样,那么我将引用 Illegal remote method in java:
All of the methods on a RMI Remote interface must declare RemoteException in their throws clause.
这意味着您需要在扩展Remote
的接口中的所有方法的声明中添加throws RemoteException
。那大概就是CustomCodeRepository
.
出现此错误:
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
对于此代码:
@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<>());
}
正如 guice 在其异常中提到的那样,它是一个嵌套异常。内部异常是:
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)
我猜你正在覆盖 java.rmi.Remote
。如果是这样,那么我将引用 Illegal remote method in java:
All of the methods on a RMI Remote interface must declare RemoteException in their throws clause.
这意味着您需要在扩展Remote
的接口中的所有方法的声明中添加throws RemoteException
。那大概就是CustomCodeRepository
.