-1

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<>());
  }
quarks
  • 33,478
  • 73
  • 290
  • 513

1 Answers1

2

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.

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35