Module development: org.openmrs.api.APIException: Service not found

This could be caused by the applicationContext file looking into a wrong project/(maven)module say for-example when your test is placed in api yet your moduleApplicationContext.xml may be in omod.

You can choose to take one of these three approaches to resolve this:

  1. Move the moduleApplicationContext.xml file to the project/(maven)module where you have the test such as: api/src/main/resources/ if your test in under api
  2. Move your test to the project/(maven)module where your moduleApplicationContext.xml
  3. Separate your moduleApplicationContext.xml into two application context files one in api and the other in omod such that the paths to each of them as; api/src/main/resources/moduleApplicationContext.xml omod/src/main/resources/webModuleApplicationContext.xml one in api project/(maven)module contains service/api specific bean definitions only where as the other contains the rest. Examples can be found at:

I prefer the last or third one :smile: this way paths are righted

2 Likes