# Trouble Shooting

## backupdatabase script has an access denied error

![Backup database error](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-cea6e0f2690688fba9347345a4e01863866f5fa1%2Fupgrade_backup_database_error.png?alt=media)\
This is because the password for root has changed from a blank password

1.Open the backup database (or backupdatabase.bat) file in Notepad and add the following to the line that starts with @mysqldump

`@mysqldump -ppassword`

password is the password of the root account, and there is no space after the -p

2.Doubleclick the backupdatabase file

## upgradedatabase script has an error - openmrs\_backup database not found

This is because the installer did not create the openmrs\_backup database. Uninstall UgandaEMR and start again

![openmrs\_backup database not found](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-2913bdb75bd10791eaa72ab0c74fa6f09d4da1f1%2Fupgrade_error_openmrs_backup_not_found.png?alt=media)

## upgradedatabase script error 2003 - Can't connect to MySQL server on local host (10061)

![Access denied to openmrs\_backup](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-57b77370f3e1b335287f97c03d74faca64dc6f30%2Fupgrade_access_denied_to_openmrs_backup.png?alt=media)\
This is because the password for root has changed from a blank password

1.Open the upgradedatabase (or upgradedatabase.bat) file in Notepad and add the following to the line that starts with @mysqldump

`@mysql -ppassword`\
password is the password of the root account, and there is no space after the -p

2.Doubleclick the upgradedatabase file

## Upgrade failed so need to reset environment

In case your upgrade fails, there is a need to restore the environment so that you can try again.

The steps are as follows:

1. Backup the openmrs database
2. Delete the openmrs and openmrs\_backup databases
3. Create a new openmrs and openmrs\_backup databases
4. On the openmrs database run the following scripts:
   * new-install.sql - this one creates a blank database for UgandaEMR
   * concept\_dictionary script - use the latest version
5. Restart your computer so that UgandaEMR can start
6. Run the upgrade again

## Error starting uploaded module

This is usually characterized by a green arrow next to the module name, an error message at the top of the Manage Modules page and a text box in the row of the module name with the words "Error starting! Click here for details"\
![Error starting module](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-eb28620b9f38a40f79a8931fae4e92e2dc3ac047%2Ferror_starting_module.png?alt=media)\
1.Click the text box to find out the details of why the module did not start:

* If the error is caused by a missing module then upload the module following the steps above
* If the error is caused by a higher version of a module, then upgrade the module to that higher version. Please note that this may cause additional errors in other modules that may be incompatible with the higher version.
* If a lower version of a module is required, then you may need to upload a lower version of the module, though this may cause other modules to fail loading

2.Restart the computer which resets all UgandaEMR services.

## UI Framework Error: Null Pointer Exception on Patient Registration

A common cause is blank entries in the address hierarchy during the upgrade process as seen in the link below\
![Null Pointer Exception on Patient Registration after Upgrade](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-051f4bb40fc0126f6018cb608d005e08abd19bb4%2Fupgrade_error_patient_reg_null_pointer.png?alt=media)

1. Click the Administration link in the top menu as below:

   <img src="https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-4a0094f38f37d1e0a93af812363dc0ce88c2dff4%2Fupgrade_error_patient_reg_null_pointer_administration_link.png?alt=media" alt="System Administration Link" data-size="original">
2. Click the Manage Address Hierarchy link on the administration dashboard

   <img src="https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-540b266db5e8aa79859a435b2ba69f8d67437afd%2Fmanage_address_hierarchy_link.png?alt=media" alt="Manage Address Hierarchy Link" data-size="original">
3. Delete all the address hierarchy entries in the rectangle which are causing the error one level at a time

   <img src="https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4YKhNOQtSxoP0vCjuG%2F-M4y-MlFbjPpenC-zM3Y%2F-M4y-XHTC9Ch8olkl5y1%2Fcleanup_address_hierarchy_level.png?generation=1586957046789145&#x26;alt=media" alt="Cleanup Address Hierarchy Levels" data-size="original">

## Address hierarchy is not installed properly with missing entries and unable to delete any levels

This happens in case there is an error when loading the entries for the address hierarchy see screenshot below

![partially loaded address hierarchy](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4YKhNOQtSxoP0vCjuG%2F-M4y-MlFbjPpenC-zM3Y%2F-M4y-XHV9oGUO37rfyxi%2Faddress_hierarchy_partially_loaded.jpeg?generation=1586957046405233\&alt=media)

The fix is by deleting the current address hierarchy entries, then restarting your computer so that it is loaded properly.

1. Backup your database
2. Run the SQL commands below:

   /*!40101 SET @OLD\_CHARACTER\_SET\_CLIENT = @@CHARACTER\_SET\_CLIENT* /;\
   /*!40101 SET @OLD\_CHARACTER\_SET\_RESULTS = @@CHARACTER\_SET\_RESULTS* /;\
   /*!40101 SET @OLD\_COLLATION\_CONNECTION = @@COLLATION\_CONNECTION* /;\
   /*!40101 SET NAMES utf8* /;\
   /*!40103 SET @OLD\_TIME\_ZONE = @@TIME\_ZONE* /;\
   /*!40103 SET TIME\_ZONE = '+00:00'* /;\
   /*!40014 SET @OLD\_UNIQUE\_CHECKS = @@UNIQUE\_CHECKS, UNIQUE\_CHECKS = 0* /;\
   /*!40014 SET @OLD\_FOREIGN\_KEY\_CHECKS = @@FOREIGN\_KEY\_CHECKS, FOREIGN\_KEY\_CHECKS = 0* /;\
   /*!40101 SET @OLD\_SQL\_MODE = @@SQL\_MODE, SQL\_MODE = 'NO\_AUTO\_VALUE\_ON\_ZERO'* /;\
   /*!40111 SET @OLD\_SQL\_NOTES = @@SQL\_NOTES, SQL\_NOTES = 0* /;

   / *The address hierarchy may be installed before so this causes problems - remove instal trail of the address hierarchy* /\
   DELETE FROM global\_property\
   WHERE property IN\
   ('address.format', 'addresshierarchy.database\_version', 'addresshierarchy.mandatory', 'addresshierarchy.started', 'metadatadeploy.bundle.version.org.openmrs.module.aijar.api.deploy.bundle.UgandaAddressMetadataBundle');

   / *Drop the address hierarchy tables if necessary* /\
   ALTER TABLE address\_hierarchy\_address\_to\_entry\_map DROP FOREIGN KEY address\_id\_to\_person\_address\_table;\
   ALTER TABLE address\_hierarchy\_address\_to\_entry\_map DROP FOREIGN KEY entry\_id\_to\_address\_hierarchy\_table;\
   ALTER TABLE address\_hierarchy\_entry DROP FOREIGN KEY level\_to\_level;\
   ALTER TABLE address\_hierarchy\_entry DROP FOREIGN KEY `parent-to-parent`;\
   ALTER TABLE address\_hierarchy\_level DROP FOREIGN KEY parent\_level;\
   DROP TABLE IF EXISTS address\_hierarchy\_address\_to\_entry\_map;\
   DROP TABLE IF EXISTS address\_hierarchy\_entry;\
   DROP TABLE IF EXISTS address\_hierarchy\_level;

   /*!40101 SET SQL\_MODE = @OLD\_SQL\_MODE* /;\
   /*!40014 SET FOREIGN\_KEY\_CHECKS = @OLD\_FOREIGN\_KEY\_CHECKS* /;\
   /*!40014 SET UNIQUE\_CHECKS = @OLD\_UNIQUE\_CHECKS* /;\
   /*!40101 SET CHARACTER\_SET\_CLIENT = @OLD\_CHARACTER\_SET\_CLIENT* /;\
   /*!40101 SET CHARACTER\_SET\_RESULTS = @OLD\_CHARACTER\_SET\_RESULTS* /;\
   /*!40101 SET COLLATION\_CONNECTION = @OLD\_COLLATION\_CONNECTION* /;\
   /*!40111 SET SQL\_NOTES = @OLD\_SQL\_NOTES* /;
3. Restart your computer

## Error starting Data Integrity Module

This error tends to happen from UgandaEMR 1.0.16 that requires this module to be available, which is based on upgrades from old versions of OpenMRS that had the data integrity module installed. The old version of a module left a dataintegrity tables installed, so the new version cannot replace some tables.

The fix involves deleting the dataintegrity\_rule table using different tools:

1. Command line

   * Connect to the database using the command

   `mysql -u openmrs -p` which will request for a password

   * Change to the openmrs database

   `use openmrs`

   * Delete the dataintegrity tables - not all of these may exist in your installation

   `DROP TABLE IF EXISTS dataintegrity_run;`\
   `DROP TABLE IF EXISTS dataintegrity_result;`\
   `DROP TABLE IF EXISTS dataintegrity_column;`\
   `DROP TABLE IF EXISTS dataintegrity_check;`\
   `DROP TABLE IF EXISTS dataintegrity_integrity_checks;`\
   `DROP TABLE IF EXISTS dataintegrity_result;`\
   `DROP TABLE IF EXISTS dataintegrity_rule;`

   * Delete previous liquibase change logs for data integrity

   `DELETE FROM liquibasechangelog WHERE ID LIKE '%data-integrity%';`

   * Restart your computer
2. Heidi SQL
   * Download the upgrade script from <https://sourceforge.net/projects/ugandaemr/files/1.0.16/dataintegritymodule_cleanup-1.0.16.sql/download>
   * Open a connection to the openmrs database on port 3306
   * Open File -> Load SQL File and load the downloaded file

## Mysql cannot start after 2.0 upgrade or installation

1. Go to start menu, search for services.
2. Under Services look for mysql.
3. Stop mysql service
4. Go to C:\ProgramData\MySQL\MySQL Server 5.5\data
5. Delete the following files:
   * ib\_logfile0
   * ib\_logfile1
6. Restart mysql from services.

## Tomcat Failing to start after 2.0 upgrade or installation

1. Go to Menu search for Launch Tomcat Manager and clink on it
2. After check the notification area and right click on tomcat icon ![](https://2263683135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4YKhNOQtSxoP0vCjuG%2Fuploads%2Fgit-blob-ffa23f67b9097197842207a85832b3302098162a%2Fwindows_notification.png?alt=media)
3. Select Configuretion and a popup window will show
4. Go to the Java Tab and select Use default.
5. Incase there are some text in the Java Options:, remove them and click apply
6. Go back to General tab and click start, to start tomcat
