Upgrade custom module built for Openmrs v1.6 to v1.9


I’m struggling with a migration task of a custom module for MDR-TB initially built for Openmrs 1.6 (Ant build.xml, SQLDiff, JDK6, i.e. the really old and retired stuff). Here’s what I did so far:

  1. Replaced the openmrs-api.jar and openmrs-web.jar to version 1.9, and make necessary updates to DAO and Services.
  2. Remove SQLDiff entirely (planning to move to liquibase).
  3. Built the module using Ant build and deployed manually on a running instance.

After getting rid of obvious errors, I’m out of clues with this error log

Apparently, the module activator isn’t launching. I tried implementing Activator as well as extended BaseModuleActivator. Here’s my config file config file and the moduleApplicationContext.xml

Hi @owais.hussain looks like there are a number of different errors happening there. Without seeing the code, I’d recommend you double check that the right classes are in the omod project and in the api project, and that the omod is including the api as a dependency.

Bigger picture, I don’t know what module this is, but it seems like it might be a fork of the mdrtb module. The original mdrtb module was migrated to run on OpenMRS 1.9.x and to use Maven long ago, so I’d recommend comparing what you are doing to the master branch (and commit history) of the mdrtb module codebase here: GitHub - openmrs/openmrs-module-mdrtb: OpenMRS MDR-TB module


1 Like

Thanks a bunch @mseaton. I searched on Addons for “MDRTB”. Found it now when I used “MDR”. Anyways, I was able to pull the module and get it to work after rebuilding.

Hi again, @mseaton

I managed to migrate all resources and get the module to build with no errors. However, on starting the module, I’m getting this error.

The key changes I’ve made:

  1. Annotated HibernateMdrtbDAO as @Component and @Autowired SessionFactory.
  2. Annotated MdrtbServiceImpl as @Service and @Autowired HibernateMdrtbDAO inside.

I double checked moduleApplicationContext.xml and the target property seems okay to me:

<property name="target">
		<property name="dao">
				<property name="sessionFactory">
					<ref bean="sessionFactory" />

What’s weird is that the test cases I created are passing.

The code is pushed on a separate branch here: openmrs/openmrs-module-mdrtb at staging-for-omrs2-upgrade (github.com)

@owais.hussain can you describe a bit more what you are trying to do? What version of OpenMRS are you trying to get the mdrtb module to work on?

@mseaton I’m trying to get it to work on v1.9.1 (spring 3). Actually I’m writing the test suite for API which didn’t exist for the module before. I’m trying to use spring annotations and auto-wiring. The module works fine without the annotations as long as the DAO and Service setters are enabled.

Hi @owais.hussain - I see. Yes, the module AFAIK, should already work on a 1.9 environment. Presumably you have specific reasons why you are trying to introduce component and service annotations and autowiring in the service and dao, but this not something that is typically done in my experience, and in some cases can dramatically slow down system startup performance.

If you are trying to introduce tests into the API layer, I’d recommend looking at other modules that are built against a minimum 1.9 version, and try to set things up the same way. For example, you may want/need to move the moduleApplicationContext.xml file into the api layer, and split the web components off into a webModuleApplicationContext.xml file in the omod layer, etc.

1 Like

Right. I browsed HFE and Reporting modules and didn’t find any annotations. Thanks for updating me on the performance issues. I’ll try to split the application context.