Re-deploying modules without webapp redeployment?

Hello all, I am new to OpenMRS so please bear with me.

I have setup the OpenMRS Ref App in the following way. I cloned the refappmod-distto module, and unzipped all the omods required for refapp. Also setup openmre-core. Now I pasted these omods which I extracted into the local OpenMrs folder into the ‘modules’ folder. To run OpenMRS, I go to openmre-core/webapp and run mvn jetty:run to get everything up and running

Here is the problem. I am tinkering around and making changes in modules like RESTWS and HTML form entry whose sources i have separately cloned. To test these changes, I have to run mvn clean install on the module source I modded.l, stop the current webapp instance, paste the new omod into the modules folder and restart the server

This is highly time-consuming and very unproductive.

I am looking for way to dynamically implement changes and have them visible directly I’m the webapp without stopping current instance and basically minimum overhead

I had spoken to @pascal regarding this over IRC but was unable to get a detailed response. Could anyone tell me, atleast in some detail what to do about this? I really need this setup ASAP thanks

PS: I am using Intellij, if that relevant

Check out these two wiki pages:

Thanks. I have a doubt here.

If I set the following in my openmrs-runtime.properties file:uiFramework.developmentFolder=/home/openmrs/code

where the ‘code’ folder contains all the module folder I am working on. I believe that development mode will be enabled for these correct?

Now, assuming I have a copy of the old .omods of the RESTWS module (which I am working on ) in the local OpenMRS/modules folder, I have done mvn jetty:run from openmrs-core/webapps and I have specified developement mode for this module as I mentioned

this old .omod will not clash with the development mode of this module?

@kakarota, I’d recommend you to use OpenMRS SDK. See for example how easy it is to start development on the openconceptlab module at https://github.com/openmrs/openmrs-module-openconceptlab/blob/master/README.md (the watch command sets up the development mode for ui framework)

4 Likes

Looks like a really good alternative Will surely check it out.

I would, however, love to set it up the way @pascal and @darius said since I believe that this is the way core developers and contributors set it up. It would also set a good precedent for new developers (students, implementers) who are looking to continue contributing in the future :slight_smile:

Actually the SDK approach is our intended future way forwards. You should try that instead.

According to the documentation that I gave you a link to, you need to also specify uiFramework.developmentModules with uiFramework.developmentFolder.

1 Like

I looked into it and it served the purpose. Just one question. When I am setting up the 2.x server for ref app, will I need to install all the modules manually the first time? Also, when I close the server, will I have to repeat the process? Does the 2.x server start with some preconfigured modules already installed?

Read the docs +/- try it out! :slight_smile:

2 Likes

I tried installing the SDK as mentioned but when I run mvn openmrs-sdk:setup-platform -DserverId=test -Dversion=1.11.2 to setup a 1.x server or even the 2.x server, I get an error:

The goal you specified requires a project to execute but there is no POM in this directory (D:/random directory). Please verify you invoked Maven from the correct directo ry.

Is there any way to resolve this? I mean it should’nt matter where I run it from correct?

@kakarota why are you trying to setup a 1.11.2 platform server?

Have you tried searching Google for a potential resolution to this error?

You probably forgot the cd command as in here:

Fork and clone Open Concept Lab module project:

$ git clone https://github.com/{yourusername}/openmrs-module-openconceptlab.git $ cd openmrs-module-openconceptlab

Why do we need to got to the folder? AFAIK, the sdk should execute from anywhere right? I just want to get the standard ref app running and this is the error. What do I do to get the standard ref app running?

Do I need to go to core, run mvn clean install and then run the reff app?

Same problem for reff app also as I mentioned

Hello @raff, @lluismf

I have successfully (somewhat) setup everything and reached the part where I can run mvn openmrs-sdk:run -DserverId=refapp. However, I get the following errors:

$ D:\kakarota\OpenMRS_CODES> mvn openmrs-sdk:run -DserverId=refapp
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- openmrs-sdk-maven-plugin:2.1.2:run (default-cli) @ standalone-pom ---
[INFO]
[INFO] Hot redeployment for controllers and gsps enabled.
[INFO]
[INFO] Configuring Jetty for project: Maven Stub Project (No POM)
[INFO] Context path = /openmrs
[INFO] Tmp directory = C:\Users\kakarota\openmrs\refapp\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
2016-04-11 01:39:12.171:INFO:oejs.Server:main: jetty-9.0.4.v20130625
2016-04-11 01:39:15.983:INFO:oejpw.PlusConfiguration:main: No Transaction manager found - if your webapp requires one, p
lease configure one.
2016-04-11 01:39:24.199:INFO:/openmrs:main: No Spring WebApplicationInitializer types detected on classpath
2016-04-11 01:39:25.224:INFO:/openmrs:main: Set web app root system property: 'webapp.root' = [C:\Users\kakarota\openmrs\ref
app\tmp\webapp]
2016-04-11 01:39:25.228:INFO:/openmrs:main: Initializing log4j from [classpath:log4j.xml]
WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2669) |2016-04-11 01:39:25,251| Unable to find a runtime properties
file at D:\kakarota\OpenMRS_CODES\openmrs-runtime.properties
WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2697) |2016-04-11 01:39:25,258| Unable to find properties file: C:\U
sers\kakarota\openmrs\refapp\openmrs-runtime.properties
WARN - OpenmrsUtil.getRuntimeProperties(2630) |2016-04-11 01:39:25,260| Unable to find a runtime properties file. Initia
l setup is needed. View the webapp to run the setup wizard.
WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2669) |2016-04-11 01:39:25,507| Unable to find a runtime properties
file at D:\kakarota\OpenMRS_CODES\openmrs-runtime.properties
WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2697) |2016-04-11 01:39:25,508| Unable to find properties file: C:\U
sers\kakarota\openmrs\refapp\openmrs-runtime.properties
WARN - OpenmrsUtil.getRuntimeProperties(2630) |2016-04-11 01:39:25,509| Unable to find a runtime properties file. Initia
l setup is needed. View the webapp to run the setup wizard.
ERROR - UpdateFilterModel.updateChanges(77) |2016-04-11 01:39:29,664| Unable to get the database changes
java.lang.RuntimeException: Error occurred while trying to get the updates needed for the database. Unable to get a conn
ection to the database.  Please check your openmrs runtime properties file and make sure you have the correct connection
.username and connection.password set
        at org.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:637)
        at org.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:594)
        at org.openmrs.web.filter.update.UpdateFilterModel.updateChanges(UpdateFilterModel.java:69)
        at org.openmrs.web.filter.update.UpdateFilterModel.<init>(UpdateFilterModel.java:47)
        at org.openmrs.web.filter.update.UpdateFilter.init(UpdateFilter.java:457)
        at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:135)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:800)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:288)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:731)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
        at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:280)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:175)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
        at org.eclipse.jetty.server.Server.start(Server.java:342)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
        at org.eclipse.jetty.server.Server.doStart(Server.java:290)
        at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:68)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:556)
        at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:352)
        at org.eclipse.jetty.maven.plugin.JettyRunWarMojo.execute(JettyRunWarMojo.java:69)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:94)
        at org.openmrs.maven.plugins.Run.execute(Run.java:134)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.
java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.Exception: Unable to get a connection to the database.  Please check your openmrs runtime propertie
s file and make sure you have the correct connection.username and connection.password set
        at org.openmrs.util.DatabaseUpdater.getLiquibase(DatabaseUpdater.java:369)
        at org.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:623)
        ... 55 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database
 server. Attempted reconnect 3 times. Giving up.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.Util.getInstance(Util.java:386)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
        at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2395)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2316)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:215)
        at org.openmrs.util.DatabaseUpdater.getConnection(DatabaseUpdater.java:431)
        at org.openmrs.util.DatabaseUpdater.getLiquibase(DatabaseUpdater.java:366)
        ... 56 more
Caused by: java.sql.SQLException: Access denied for kakarota 'test'@'localhost' (using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:928)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1750)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1290)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493)
        at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2334)

From the looks of it, the error says that it is a problem with my database connection but I am not sure how. I have the ‘openmrs’ database setup and can successfully run the webapp from core like I used to,

I used the following command as reference to setup my server as mentioned on the wiki:

mvn openmrs-sdk:setup -DserverId=refapp -Dversion=2.3 -DdbDriver=mysql -DdbUser=root -DdbUri=jdbc:mysql://localhost:3306/@DBNAME -DdbPassword=12345

As per the instructions in wiki, I have changed this to:

mvn openmrs-sdk:setup -DserverId=refapp-Dversion=2.3 -DdbDriver=mysql -DdbUser=root -DdbUri=jdbc:mysql://localhost:3306/openmrs -DdbPassword=admin123

Notice the changed DB name and the correct password. I can access this database from MySQL terminal as root with password ‘admin123’ so there is definitely no problem with the username and password.

Can someone please tell me what’s wrong? Thanks again.

@kakarota, did you try accessing http://localhost:8080/openmrs in a browser? The error may be false alarm.