Method call problem

Hello ,
when i make my method call i get this error do you know what it is? I tried changing the method and it’s still the same. Thanks in advance.

java.lang.NoSuchMethodError: com.axelor.apps.contract.service.ContractService.testActif()V
at com.axelor.apps.contract.web.ContractsController.testActif(ContractsController.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.axelor.meta.ActionHandler.call(ActionHandler.java:256)
at com.axelor.meta.schema.actions.ActionMethod.evaluate(ActionMethod.java:76)
at com.axelor.meta.schema.actions.Action.execute(Action.java:100)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:109)
at com.axelor.meta.schema.actions.ActionGroup.evaluate(ActionGroup.java:231)
at com.axelor.meta.schema.actions.Action.execute(Action.java:96)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:109)
at com.axelor.meta.ActionHandler.execute(ActionHandler.java:524)
at com.axelor.meta.ActionExecutor.execute(ActionExecutor.java:57)
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$90d7ab77.CGLIB$execute$0()
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$90d7ab77$$FastClassByGuice$$b3c9dd3b.invoke()
at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228)
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:76)

I noticed that I had the error only when I added these two lines above the alert() which on its own works. I don’t understand…help plz

public void testActif(ActionRequest request, ActionResponse response) {
ContractService contractService = Beans.get(ContractService.class);
contractService.testActive();
response.setAlert(« Test execute »);
}

I put a breakpoint in the method, the program does not even render in the testActive() method…

can you share gist about service class

Hi Siddique,

yes and thanks for your help.

My implementation is :

package com.axelor.apps.contract.service;

import com.axelor.apps.contract.db.repo.ContractRepository;
import com.axelor.apps.project.db.repo.ProjectRepository;
import com.google.inject.Inject;
import org.slf4j.LoggerFactory;

public class ContractServiceImpl implements ContractService {
  protected final org.slf4j.Logger log = LoggerFactory.getLogger(getClass());

  protected ContractRepository contractRepository;
  // protected ProjectRepository projectRepository;

  @Inject
  public ContractServiceImpl(
      ContractRepository contractRepository, ProjectRepository projectRepository) {
    this.contractRepository = contractRepository;
    //  this.projectRepository = projectRepository;
  }

  @Override
  public void archiverRecurcif(Long idContrat, boolean etatArchive) {

    System.out.println("it's ok 1");

  }


  @Override
  public void testActive() {
    System.out.println("test OK");
  }
}

My interface is :

package com.axelor.apps.contract.service;

public interface ContractService {
  public void archiverRecurcif(Long idContrat, boolean etatArchive);

  public void testActive();
}

You forget to bind your service in the Axelor Module file

Use this :

@Override
protected void configure() {
    bind(ContractService.class).to(ContractServiceImpl.class);
}

in a file at the root of your module. This file can be named by what you want but must extends the AxelorModule class.

Example file : https://github.com/axelor/axelor-open-suite/blob/a9e63e788c6d038baceae8685d1bb8d42d522333/axelor-account/src/main/java/com/axelor/apps/account/module/AccountModule.java

Hi PHPierre,

Thanks but I had already implemented this class. So the problem doesn’t seem to come from there.

package com.axelor.apps.contract.module;

import com.axelor.app.AxelorModule;
import com.axelor.apps.contract.service.ContractService;
import com.axelor.apps.contract.service.ContractServiceImpl;

public class ContractModule extends AxelorModule {

  @Override
  protected void configure() {
    bind(ContractService.class).to(ContractServiceImpl.class);
  }
}

If you use Eclipse, have you cleared the project cache ?

can you share where are your java files exists

yes i use eclipse and i have clean project. Delete import project but it’s not ok. I try rewrite my method… :’(

I don’t understand

can you share folder structure you adopted

I found the problem by going back to my whole implementation from the beginning. In fact it was a method naming problem in the class of the web package and that of the service. Thank you for your support.