Beans from an external jar (dependency)

Application Name: Platform Version Number: 2.0.1

Question: I’ve created a module (Module A) with a dependency to another module (Module B). But, although I can access the classes from module B, it seems that I cannot access the beans since the injection of autowired dependencies is failing, saying that there are no such bean definitions.

Researching around, I’ve found out that I may have to import the moduleApplicationContext.xml files and config.xml files from module B in order to access the bean definitions and use the beans.

How do I do this in an openmrs module? Any help would be greatly appreciated! :slight_smile:

Can you give details of the stack trace? It would also help to point us to the module source if it is on github.

Here is the stack trace: https://pastebin.com/v6WBRNAH

My module is on gitlab so I can’t attach it here. But I can tell you that it’s just a newly created module with just one controller extending a class from the “Module B”. The problem is that the class from module B is using a service I created, which I defined as a bean in “Module B’s” moduleApplicationContext.xml.

Do I have to define the bean in Module A’s moduleApplicationContext.xml again?

Can you point us to the gitlab url?

Here’s “module A”:

Here’s “module B”

Is the bean which implements PatientQueueDAO configured in spring?

Yes. And everything is working and configured in “Module B” (The core module). It’s only when I upload the “Module A” that I get this error, when all I did is extend a class from module B.

Have you added a require module element in config.xml?

I added an “aware of module” element in Module A (The new module).

Can you allow readonly access to your module on gitlab for non logged on users?

I’m sorry but I can’t because I only have developer access right now.

I just want to know if there’s at least an existing openmrs module out there that utilizes a bean from another module so I’d know how to do it.

Were you able to make it work?

Any idea how we can do this?

In config.xml for module A, make sure module B appears in the require_modules or aware_of_modules list, but it’s much more relevant where you are trying to autowire the component, i.e., can the class you’re trying to autowire actually be autowired?

1 Like

I was autowiring the bean which was not created by spring. Here can find how we can do this. Thanks to @ibacher for solution.