user3141985
user3141985

Reputation: 1385

Environment variable DHIS2_HOME: null (TrayApp.java [main])

I am getting the error Environment variable DHIS2_HOME: null (TrayApp.java [main]) when trying to start the dhis2-live.exe with Postgres connection on my Windows Vista machine.

However the same application runs fine if the H2 DB is used, but as per requirement I need to work with Postgres.

Here is the log file.

* INFO  23:48:27,232 Environment variable DHIS2_HOME: null (TrayApp.java [main])
* INFO  23:48:27,700 Initialising DHIS 2 Live... (TrayApp.java [main])
* INFO  23:48:28,574 Loading DHIS 2 on port: 8082 (WebAppServer.java [main])
* INFO  23:48:28,745 Setting DHIS 2 web app context to: /D:/dhis-live/webapps/dhis (WebAppServer.java [main])
* INFO  23:48:28,745 Lifecycle: server starting (TrayApp.java [Thread-2])
* INFO  23:48:55,001 System property dhis2.home points to /D:/dhis-live/conf (DefaultLocationManager.java [Thread-2])
* INFO  23:49:00,290 Hibernate configuration loaded, using dialect: org.hibernate.dialect.PostgreSQLDialect (DefaultHibernateConfigurationProvider.java [Thread-2])
* INFO  23:50:32,286 Found the following message senders: [org.hisp.dhis.message.EmailMessageSender@c0023f, org.hisp.dhis.sms.SmsMessageSender@b027dd] (DefaultMessageService.java [Thread-2])
* INFO  23:51:25,998 Lifecycle: server started (TrayApp.java [Thread-2])

hibernate.properties

#hibernate.dialect = org.hibernate.dialect.H2Dialect
#hibernate.connection.driver_class = org.h2.Driver
#hibernate.connection.url = jdbc:h2:./database/dhis2;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE
#hibernate.connection.username = sa
#hibernate.connection.password =

hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql:dhis2
hibernate.connection.username = dhis
hibernate.connection.password = dhis

hibernate.hbm2ddl.auto = update

Upvotes: 4

Views: 1297

Answers (2)

user3141985
user3141985

Reputation: 1385

@Ranjitsinh's answer might be helpful to some of the future readers, but for me the problem was re-solved by creating a new DB and used the default user postgres with privileges set as shown below in screen shot.

Previously I had removed the public User/Group privilege from the DB.

enter image description here

Upvotes: 1

Ranjitsinh
Ranjitsinh

Reputation: 1349

Actually, TrayApp.java file will be used to read the initial configuration using location which we have set in DHIS2_HOME variable.

Please follow the below steps:

  1. Create one DHIS2_HOME system variable with value of your location like D:\dhis2
  2. Create hibernate.properties file in this location with following configuration

    hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
    hibernate.connection.driver_class = org.postgresql.Driver
    hibernate.connection.url = jdbc:postgresql:dhis2
    hibernate.connection.username = dhis
    hibernate.connection.password = dhis
    hibernate.hbm2ddl.auto = update

Now click on dhis2-live.exe to start the dhis2 application with posgresql.

Hope it may help you.!!

Upvotes: 2

Related Questions