1

I'm leveraging the interoperability between Scala and Java and have the below code that uses Scala, to instantiate a class in the same project that was written in Java. The CommandExecutor parameter is inherited from a parent class.

class IdmIdentityServiceImpl extends ServiceImpl with IdmIdentityService {
    override def createNativeUserQuery: NativeUserQuery = {
        new NativeUserQueryImpl(commandExecutor)
      }
}

I get an error, in instantiating NativeUserQueryImpl that says cannot resolve constructor

NativeUserQueryImpl was written in Java, but I've been reading about the interoperability between Java and Scala and feel like it should work.

This is the NativeUserQueryImpl class, which takes in that CommandExecutor type in one of it's constructors. The class comes from the flowable-engine library.

public class NativeUserQueryImpl extends AbstractNativeQuery<NativeUserQuery, User> implements NativeUserQuery {

  private static final long serialVersionUID = 1L;

  public NativeUserQueryImpl(CommandContext commandContext) {
    super(commandContext);
  }

  public NativeUserQueryImpl(CommandExecutor commandExecutor) {
    super(commandExecutor);
  }

  // results ////////////////////////////////////////////////////////////////

  public List<User> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
    return commandContext.getUserEntityManager().findUsersByNativeQuery(parameterMap, firstResult, maxResults);
  }

  public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
    return commandContext.getUserEntityManager().findUserCountByNativeQuery(parameterMap);
  }

}

EDIT:

Full error

Error:(31, 5) overloaded method constructor NativeUserQueryImpl with alternatives:
  (x$1: org.flowable.idm.engine.impl.interceptor.CommandExecutor)org.flowable.idm.engine.impl.NativeUserQueryImpl <and>
  (x$1: org.flowable.idm.engine.impl.interceptor.CommandContext)org.flowable.idm.engine.impl.NativeUserQueryImpl
 cannot be applied to (org.flowable.engine.impl.interceptor.CommandExecutor)
    new NativeUserQueryImpl(commandExecutor)
7
  • Where is commandExecutor defined? Commented Jan 23, 2017 at 16:38
  • @nmat in the same project Commented Jan 23, 2017 at 16:38
  • It's inherited from a parent class. I'm adding the full class signature that this is contained in. It is in ServiceImpl Commented Jan 23, 2017 at 16:40
  • Looks like it should work. Can you post the full output of the compiler error? Commented Jan 23, 2017 at 16:41
  • It's just exactly that cannot resolve constructor Commented Jan 23, 2017 at 16:42

1 Answer 1

1

From the full error posted in the original question, it appears that the CommandExecutor that is inherited from the parent class ServiceImpl has two different versions in the library

org.flowable.idm.engine.impl.interceptor.CommandExecutor and org.flowable.engine.impl.interceptor.CommandExecutor where the subtle difference is that one is from an idm package and one is not.

Changing ServiceImpl from the second package to the first, updates the CommandExecutor parameter that's being passed in, and fixes the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.