How to run two instances of OpenMRS 2x?

I would like run two instances of OpenMRS in same tomcat.

  • OpenMRS 2.0.4.1 & Reference Application 2.5
  • OpenMRS 2.0.5 & Reference Application 2.6

How to change the location for .OpenMRS folder for both instance to avoid conflict?

Why would you want to do this?

I should keep the old version running. in same time i need to setup the new version and test each part. Therefore, I need both instances running in same server.

How about just downloading the reference application 2.6 standalone version and test that?

I should customize some parts and add reports for each encounter.

I can change the openmrs.war file name and rename one as openmrs2.war but still both will refer to same .OpenMRS folder.

Would the standalone version prevent you from doing so? For an openmrs2.war, its data will be in .OpenMRS/openmrs2

Solution 1 : I have made following changes web.xml file and generated war file and it worked fine in widows base operating system but failed in ubuntu environment.

<context-param>
        <param-name>application.data.directory</param-name>
        <param-value>${user.home}/OpenMRS25</param-value>
</context-param>

Also changed the openmrs.war file to openmrs25.war

Solution 2: I made the changes in following piece of code and replaced the OpenMRS to OpenMRS25

//		String systemProperty = System.getProperty(OpenmrsConstants.KEY_OPENMRS_APPLICATION_DATA_DIRECTORY);
//		//System and runtime property take precedence
//		if (systemProperty != null) {
//			filepath = systemProperty;
//		} else {
//			String runtimeProperty = Context.getRuntimeProperties().getProperty(
//			    OpenmrsConstants.APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY, null);
//			if (runtimeProperty != null) {
//				filepath = runtimeProperty;
//			}
//		}

if (filepath == null) {
	if (OpenmrsConstants.UNIX_BASED_OPERATING_SYSTEM) {
		filepath = System.getProperty("user.home") + File.separator + ".OpenMRS25";
		if (!canWrite(new File(filepath))) {
			log.warn("Unable to write to users home dir, fallback to: "
			        + OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX);
			filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX + File.separator + "OpenMRS25";
		}
	} else {
		if (OpenmrsConstants.UNIX_BASED_OPERATING_SYSTEM) {
			filepath = System.getProperty("user.home") + File.separator + ".OpenMRS25";
			if (!canWrite(new File(filepath))) {
				log.warn("Unable to write to users home dir, fallback to: "
				        + OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX);
				filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_UNIX + File.separator + "OpenMRS25";
			}
		} else {
			filepath = System.getProperty("user.home") + File.separator + "Application Data" + File.separator
			        + "OpenMRS25";
			if (!canWrite(new File(filepath))) {
				log.warn("Unable to write to users home dir, fallback to: "
				        + OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_WIN);
				filepath = OpenmrsConstants.APPLICATION_DATA_DIRECTORY_FALLBACK_WIN + File.separator + "OpenMRS25";
			}
		}
	}
	
	filepath = filepath + File.separator;
}LBACK_WIN + File.separator + "OpenMRS25";
    			}
    		}
    	}
    	
    	filepath = filepath + File.separator;
    }

Second solution is the best way to have multiple instances in same container.

You should be able to run multiple instances in the same tomcat without modifying the platform. Did you try to rename the war files? https://wiki.openmrs.org/display/docs/Multiple+Instances+of+OpenMRS

I tried that but still all instances will refer to same OpenMRS folder. But in my scenario, I want a different OpenMRS folder for each instance.

Hello @hpardess did you manage to solve the issue?