Connect to vagarnt database getPatient value getting Error context null

Hi, @tendomart @danfuterman @dkayiwa @darius

I am using ubuntu . I have installed bahmni in vagrant .I want to connect vagrant bahmni to our java code

import java.util.List;
import java.util.Properties;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
import org.openmrs.module.ModuleMustStartException;
import org.openmrs.util.DatabaseUpdateException;
import org.openmrs.util.InputRequiredException;
import org.openmrs.util.OpenmrsUtil;

public class Test {

public static void main(String[] args) {
	  File propsFile = new File(OpenmrsUtil.getApplicationDataDirectory(), "");
	  Properties props = new Properties();
	  OpenmrsUtil.loadProperties(props, propsFile);
	  System.out.println(props+"   "+propsFile);
	  try {
		Context.startup("jdbc:mysql://", "uopenmrs", "openmrs", props);
	  } catch (ModuleMustStartException | DatabaseUpdateException | InputRequiredException e) {
	  try {
	      Context.authenticate("superman", "Admin123");
	    System.out.println("govind run");
	    List<Patient> patients = Context.getPatientService().getPatients("govind");
	   for (Patient patient : patients) {
	      System.out.println("Found patient with name " + patient.getPersonName() + " and uuid: " + patient.getUuid());
	  finally {


----------------------------------------Getting Eror In Console Eclipse---------------------------------------

  • PropertyFile :/home/tattva/.OpenMRS/
  • {encryption.vector=fXAGMx/ziLvlbUvqN0XFmw==, module.allow_web_admin=true, connection.url=jdbc:mysql://localhost:3306/openmrs?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8, connection.username=openmrs_user, encryption.key=9qQItDyCFsfRYTZIFO4GAw==, auto_update_database=false, connection.password=5GG0ltTcddG@} /home/tattva/.OpenMRS/
  • Strup :username uopenmrs
  • password openmrs
  • properties jdbc:mysql://
  • null
  • null
  • log4j:WARN No appenders could be found for logger (org.openmrs.api.context.Context).
  • log4j:WARN Please initialize the log4j system properly.
  • Exception in thread “main” org.openmrs.api.APIException: contextDAO is null
  • at org.openmrs.api.context.Context.getContextDAO(
  • at org.openmrs.api.context.Context.openSession(
  • at org.openmrs.api.context.Context.startup(
  • at Test.main( [/poll]

I think using the API that way might be broken in later versions, if you try a 1.9-1.11 version it should work, therefore it might be a bug that needs to be fixed.

Hi, can i connect vagrant bahmni database to aur localMachine eclipse code for creating Custom rest Api