Steps to accessing code from a different module

I have created two different modules. Is there a step by step tutorial on how to be able to use services from another module? I want to know the exact steps, because I might be missing something that’s causing the error.

Steps that I have already done:

  1. Added dependency in the dependent module’s api pom
  2. Added dependency in the dependent module’s omod pom
  3. Added dependency in the dependent module’s root pom
  4. Added <required_modules> in config.xml of dependent module

But even after this, it still shows the APIException Service not found error

In your dependency pom files, did you remember to set the scope to provided as here? https://github.com/openmrs/openmrs-module-xforms/blob/master/api/pom.xml#L54

If you did the above but still get the error, these steps look correct. In such cases where you have done everything as expected but still getting the error, you may need to share the full module for us to try reproduce it locally and investigate what could be going on.

A paste link to the full stack trace is also usually helpful.

1 Like

I already did that before, but I didn’t declare it in the root pom. When I declared it in the root pom, I didn’t declare it in the api and omod pom. Now that’s there’s a scope set to provided in all 3 pom files, it finally worked. Thank you very much for replying!