bahmni-erp-connect application properties not getting overridden by system or env properties



  • Bahmni-erp-connect loads all properties from a packaged file "".

  • The properties are loaded such a way that one can not override the properties through system or env variables. For example: if the openerp instance is not on localhost, then this can not be overriden. same for any other properties like user/pwd for other systems (OpenMRS, OpenELIS etc). By convention, all bahmni services properties should be externalizable and for this specific service, it is done through
    "/opt/bahmni-erp-connect/etc/bahmni-erp-connect.conf". Right now, this is not so.

  • Also, some of the beans are getting registered twice. This can be validated by using a @PostConstruct annotated method in "".

Additional Context
1. Bahmni-erp-connect is an integrator service doing the sync between OpenMRS<->OpenERP
2. Bahmni-erp-connect is essentially the openerp-atomfeed-service packaged to run with embedded tomcat.

Building Bahmni-erp-connect
1. in "openerp-atomfeed-service": mvn clean install

  • will generate "openerp-atomfeed-service.war"
    2. Copy the war file to bahmni-package/bahmni-erp-connect/resources

  • cd to bahmni-package/bahmni-erp-connect

  • ./gradlew buildrpm to build the rpm

  • you might want to bump up the version of the rpm. To do so, you can change "bahmni-package/" => bahmniRelease
    3. Copy the rpm to target machine.

  • install by command: rpm -Uvh <bahmni-erp-connect-0.92-1.noarch.rpm>

In Scope:
1. "openERPFeedServiceContext.xml" - change definition of

  • <contextroperty-placeholder location=""/>
    to something like below (or use appropriate properties when using the <contextroperty-placeholder>

  • <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <property name="searchSystemEnvironment" value="true"/>
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>

2. the "web.xml" file registers 2 contexts, and also has duplicate component scanning. One is through dispatcher servlet, and the other through contextConfigListener. There are several times the components are getting scanned and recreated.

  • "openerpmvc-config.xml"

  • openERPFeedServiceContext.xml

  • applicationContext-openerp-client

Separate out the atomfeed library component definitions in another context file. (right now, its loaded from "atomFeedContext.xml" imported from dependency "atomfeed-spring-server.jar")
In "openERPFeedServiceContext.xml"
a) remove the line
<import resource="classpath:atomFeedContext.xml"/>
b) add a new context xml (e.g. erp-atomfeed-context.xml) with the content of the "atomFeedContext.xml" but replace the properties definition: <contextroperty-placeholder location="classpath*:*.properties"/>

c) import the new context xml in "openERPFeedServiceContext.xml"
<import resource="classpath:erp-atomfeed-context.xml"/>

4. Refactor ""

  • Don't use ResourceBundle to load the properties.

  • use annotation like "@Value("${}") over appropriate fields. use the field(s) to return value for the methods.

Pointers to Test
1. Ensure that the properties are loaded only once.

  • For this, modify the log4j.xml file (bahmni-erp-connect/WEB-INF/classes/log4j.xml) and change level to DEBUG.

  • Check the output (either in /home/bahmni/nohup.out or /var/log/bahmni-erp-connect/bahmni-erp-connect.log) for the text "DEBUG OpenERPAtomFeedProperties", the properties will be listed below.

2. Ensure that you can change the properties from external means
There are 2 ways to do so (lets take example of "scheduler.initial.delay" property)
a) From java command line: you can use "-D" options to pass any parameter. However to do this, you will have to change the "bahmni-erp-connect/bin/" to something like

> " .... java -jar -Dscheduler.start.delay=12500 $SERVER_OPTS /opt/bahmni-erp-connect/lib/bahmni-erp-connect.jar ... "

Note the above is in plain text, but you can inject through another system variable and use something like
> " .... java -jar -Dscheduler.start.delay=$SCHEUDLER_START_DELAY $SERVER_OPTS /opt/bahmni-erp-connect/lib/bahmni-erp-connect.jar ... "

the SCHEUDLER_START_DELAY can be specified in "bahmni-erp-connect/etc/bahmni-erp-connect.conf". This conf file lists all env variables that are exported first. The reason for capitalisation/renaming to "SCHEUDLER_START_DELAY" is that "." (dot) is allowed for variable exported from system commands.

b) From external file configuration: bahmni-erp-connect properties now can be overridden by another file that needs to be mentioned through a system property called "APP_PROPERTIES_FILE". So you can create a file where the application can read from (must have rights) and mention the file location as the above parameter. For example
i) Create a file "/home/bahmni/" and add the property

ii) in "bahmni-erp-connect/etc/bahmni-erp-connect.conf", export a property
export APP_PROPERTIES_FILE=file:/home/bahmni/

Restart bahmni-erp-connect service and check the properties. You can use this to change database connection properties as well (E.g. username, password).

Few other things to test
1. Make sure you can access the following URLs and have some results returned (to be hit from the machine the service runs)

curl http://localhost:8053/bahmni-erp-connect/tasks
curl http://localhost:8053/bahmni-erp-connect/feed/product/recent

2. Ensure that the integration of OpenMRS and OpenERP are working fine.

  • Create a concept with class Radiology and ensure it syncs to ERP as product

  • Order the concept and see a quotation is raised in ERP



Angshuman Sarkar
February 28, 2019, 2:19 PM

This must be resolved first before any work on BAH-406

Himabindu Akkinepalli
April 23, 2019, 6:49 AM
Angshuman Sarkar
April 26, 2019, 12:53 PM

Tested on qa08 (0.91 patch)

  • with command line parameter. edited "/opt/bahmni-erp-connect/bin/" to add -D parameter
    > nohup $JAVA_HOME/bin/java -jar -Dscheduler.initial.delay=30000 $SERVER_OPTS /opt/bahmni-erp-connect/lib/bahmni-erp-connect.jar &
    > echo $! > /var/run/bahmni-erp-connect/

  • change "/opt/bahmni-erp-connect/bahmni-erp-connect/WEB-INF/classes/log4j.xml" to change root logger level to 'DEBUG'. also added a console appender

<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [openerp-atomfeed-service] [%c] %m%n"/>

<priority value="DEBUG"/>
<appender-ref ref="fileAppender"/>
<appender-ref ref="console"/>

  • restarted bahmni-erp-connect service, check /home/bahmni/nohup.out, and verified that "scheduler.initial.delay=30000" instead of default 60000

Angshuman Sarkar
April 26, 2019, 1:08 PM

Tested on product-qa08 (0.91 patch) with "APP_PROPERTIES_FILE"

  • added a file "/home/bahmni/", containing a variable
    > scheduler.initial.delay=15000

  • changed "/opt/bahmni-erp-connect/etc/bahmni-erp-connect.conf" and added line
    > export APP_PROPERTIES_FILE=file:/home/bahmni/

  • restart "bahmni-erp-connect" service

  • checked /home/bahmni/nohup.out, and verified that "scheduler.initial.delay=15000" instead of default 60000

Angshuman Sarkar
April 26, 2019, 1:23 PM
  • verified the above 2 approaches (using cmd line pararmeter using -D option, and also using external APP_PROPERTIES_FILE) on qa03 (0.92)



Angshuman Sarkar


Angshuman Sarkar










External issue ID


UAT Assignee

angshuman sarkar


Himabindu Akkinepalli



0.93 Product M1

Fix versions