Hibernate error while installing OpenMRS

Application Name: Platform Version Number: 2.0.5

Question: I’m try to install and configure an OpenMRS Platform version 2.0.5 on a Digital Ocean droplet (Ubuntu 16.04.3). I had a server previously running on the same droplet and it was working smoothly. I deleted the previous server recently and wanted to install a new one. I followed the same install steps as before per the installation guide.

However, after completing the Initial setup wizard steps, I get the following error.

HTTP Status 500 - Could not open Hibernate Session; nested exception is org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]

Stack trace of error from tomcat logs:

Aug 24, 2017 2:54:22 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [default] in context with path [/openmrs] threw exception org.springframework.dao.DataAccessResourceFailureException: Could not open Hibernate Session; nested exception is org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider] at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.openSession(OpenSessionInViewFilter.java:208) at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:139) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:201) at org.hibernate.internal.AbstractSessionImpl.getJdbcConnectionAccess(AbstractSessionImpl.java:341) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.(JdbcCoordinatorImpl.java:114) at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.(TransactionCoordinatorImpl.java:89) at org.hibernate.internal.SessionImpl.(SessionImpl.java:258) at org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl.openSession(SessionFactoryImpl.java:1589) at org.hibernate.internal.SessionFactoryImpl.openSession(SessionFactoryImpl.java:999) at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.openSession(OpenSessionInViewFilter.java:203) … 32 more

I double checked my openmrs-runtime.properties file. This is what it has,

#Auto generated by OpenMRS initialization wizard #Thu Aug 24 11:11:21 UTC 2017 encryption.vector=GDL/T4omuNYBG2USCEAorg== connection.url=jdbc:mysql://localhost:3306/openmrs?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8 module.allow_web_admin=true connection.username=openmrs_user auto_update_database=true encryption.key=6epwP23Kfo5jnLYxyssj3w== connection.password=mvTHKowT4zxJ

I’ve uploaded my server log file below

openmrs.log.txt (91.9 KB)

Really can’t understand what’s causing this issue or how to fix it. Help is much appreciated!

Is the legacyui module installed and started?

I haven’t even got to that point yet. There are no modules in the modules folder of the server

How exactly are you doing this installation? When i see something like this in your log “java.io.FileNotFoundException: /var/lib/tomcat7/webapps/openmrs/WEB-INF/view/module/webservices/rest/resources.jsp” i get tempted to think that you could still be using an old installation that already had modules expanded in the webapp folder.

Install steps:

  1. Installed all pre-requisites: Java 1.8, Tomcat7, MySql 5.6, Firefox
  2. Created a directory /var/lib/OpenMRS and gave ownership of that directory to tomcat7
  3. Downloaded the platform v 2.0.5 war file from sourceforge
  4. Unzipped the files into a folder called openmrs into my tomcat7 webapps folder (at /var/lib/tomcat7/webapps)
  5. Restarted tomcat
  6. Checked to see that openmrs was deployed on my tomcat manager console, it was
  7. Went to :8080/openmrs
  8. Followed initial setup with the following initial conditions:

OpenMRS 2.0.5 Installation Wizard

Review All required input has been collected and is ready to be processed. Click the “finish” button to create tables, data, etc. This could take up to several minutes. When complete you will be taken to the OpenMRS main screen. Database Database connection jdbc:mysql://localhost:3306/@DBNAME@?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8 Database name openmrs Create database Yes Create database user account Yes Create tables Yes Add demo data No Implementation information Implementation name Intelehealth AFI testing env Implementation ID AFI_TEST Implementation pass phrase

Implementation description

Runtime properties Enable uploading modules from the web interface Yes Update the database automatically on start up when a new release is deployed Yes Runtime properties file path /var/lib/OpenMRS/openmrs-runtime.properties

The wizard was able to successfully create a database and database tables.

The following files and directories were created in my /var/lib/OpenMRS directory,

activemq-data
liquibaseUpdateLogs.txt
modules
openmrs-runtime.properties
person_images chartsearch
lucene
openmrs.log
owa

Note: Modules folder is empty.

After these steps are completed by the wizard, I get this error.

Usually once the wizard completes its steps a screen saying that openmrs has been successfully installed and that no UI module was found. At this point I put the module omod files into the directory

I am not getting to that screen at all.

@ngoel2 you mechanicallly dropped the omods into the installation?

Clarification:

After completing install steps mentioned above, the wizard runs through its steps and usually reaches this screen

After this screen is reached I mechanically drop the omod files into the installation and restart tomcat. However, I got this error before I dropped the modules in. So at the point the error occured, there were no modules in the server’s modules folder.

UPDATE: After you mentioned about installing and starting the legacy UI module, I dropped all default ref app 2.6 distro modules into the modules folder, including the legacy UI module.

Here are the steps I followed:

  1. dropped all omod files into /var/lib/OpenMRS/modules
  2. restarted tomcat
  3. reloaded [ip-address]:8080/openmrs

Now I get this error:

The following error occurred at startup: Unable to start OpenMRS. Error thrown was: org.openmrs.module.ModuleException: Unable to initialize servlet: org.openmrs.web.dwr.OpenmrsDWRServlet@3f70456d Module: legacyui org.openmrs.module.ModuleException: Unable to start OpenMRS. Error thrown was: org.openmrs.module.ModuleException: Unable to initialize servlet: org.openmrs.web.dwr.OpenmrsDWRServlet@3f70456d Module: legacyui at org.openmrs.web.WebDaemon.startOpenmrs(WebDaemon.java:65) at org.openmrs.web.Listener.contextInitialized(Listener.java:196) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1259) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1998) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: javax.servlet.ServletException: org.openmrs.module.ModuleException: Unable to initialize servlet: org.openmrs.web.dwr.OpenmrsDWRServlet@3f70456d Module: legacyui at org.openmrs.web.Listener.startOpenmrs(Listener.java:276) at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42) Caused by: org.openmrs.module.ModuleException: Unable to initialize servlet: org.openmrs.web.dwr.OpenmrsDWRServlet@3f70456d Module: legacyui at org.openmrs.module.web.WebModuleUtil.loadServlets(WebModuleUtil.java:478) at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:709) at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:637) at org.openmrs.web.Listener.startOpenmrs(Listener.java:268) … 1 more Caused by: javax.servlet.ServletException: java.io.IOException: Missing config file: ‘/WEB-INF/dwr-modules.xml’ at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:90) at org.openmrs.web.dwr.OpenmrsDWRServlet.init(OpenmrsDWRServlet.java:46) at org.openmrs.module.web.WebModuleUtil.loadServlets(WebModuleUtil.java:474) … 4 more Caused by: java.io.IOException: Missing config file: ‘/WEB-INF/dwr-modules.xml’ at org.directwebremoting.impl.DwrXmlConfigurator.setServletResourceName(DwrXmlConfigurator.java:83) at org.directwebremoting.impl.ContainerUtil.configureFromInitParams(ContainerUtil.java:296) at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:412) at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79) … 6 more

Can you check to see if that file really does not exist? Or does it exist but a permission restriction.

The file ‘dwr-modules.xml’ does not exist at /WEB-INF

Only the following files exist in that directory:

bundledModules classes lib openmrs_static_content-servlet.xml view web.xml

Can you ensure that this process or tomcat has permission to create files in that directory?

Yes it does. I had given ownership of that directory to tomcat.

UPDATE: I thought it may be a permissions problem with the application directory since I was running the application at /var/lib/OpenMRS. So I followed this Talk post and redeployed the application at /usr/share/tomcat7/.OpenMRS.

This took care of a lot of the warnings I was getting in my log files where openmrs kept looking for files in the /usr/share/tomcat7 directory, not finding them and falling back to the /var/lib directory.

But it did not solve the problem. I am still getting the same error.

I’m wondering what I’m doing wrong!

Directory permissions:

/usr/share/tomcat7# ls -l -a

drwxr-xr-x 6 root root 4096 Aug 24 15:13 . drwxr-xr-x 134 root root 4096 Aug 18 04:24 … drwxr-xr-x 2 root root 4096 Aug 7 16:50 bin -rw-r–r-- 1 root root 39 Feb 18 2016 defaults.md5sum -rw-r–r-- 1 root root 1958 Feb 18 2016 defaults.template drwxr-xr-x 2 root root 4096 Aug 7 16:50 lib -rw-r–r-- 1 root root 53 Feb 18 2016 logrotate.md5sum -rw-r–r-- 1 root root 118 Feb 18 2016 logrotate.template > drwxr-xr-x 9 tomcat7 tomcat7 4096 Aug 24 17:10 .OpenMRS drwxr-xr-x 4 root root 4096 Aug 7 16:52 skel

Still facing this problem!!! @dkayiwa - any suggestions??

Do you think you can get some time and ping me on IRC?

@dkayiwa - I was able to fix the issue, it turned out to be a permissions problem after all.

I had downloaded the ref app distro omod files from sourceforge as a zip file and used the sudo command to unzip them into the OpenMRS server’s modules folder. Because I had used sudo, the ownership of the omod files was root and not tomcat7. Running chown and assigning the ownership to tomcat7 solved the error.

1 Like

@ngoel2 Excellent! Thanks for diving into it and reporting back. :slight_smile: