Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Monday, February 25, 2013

Error with starting OpenMRS - "Unable to get a connection to the database"

This blog post will be about a very primary error on starting and running OpenMRS medical record system, in which i did my gsoc project and where i am still contributing whenever i get a time (yes i still love openmrs!). This is more like a note to myself.

I recently started to use a new laptop, therefore i moved all my openmrs repositories, .m2 repository and .OpenMRS directories into the new machine, as my intention was saving the time that will be taken to build everything from scratch again. However when i tried to run OpenMRS in the new machine, after installing and setting up mysql server, it returned the following error.

java.lang.RuntimeException: Error occurred while trying to get the updates needed for the database.
Unable to get a connection to the database.  Please check your openmrs 
runtime properties file and make sure you have the correct 
connection.username and
connection.password set ...
.................................................................................
.................................................................................
Caused by: java.sql.SQLException: Access denied for user 'openmrs_user'@'localhost' (using password: YES)


 Although i have worked with the project over an year now, i was also first confused on why the webapp can not be started. But then i realized the fix.

This is simply because when we start the web app from a previous implementation it still uses some of the configuration from its past installation. 
If you go to "webapp" folder in the 'openmrs_home' repository, there is a file called "openmrs-runtime.properties" where there is previous configuration data (usernames, passwords etc.) still present. Now simply delete this file from /home/USER_NAME/.OpenMRS folder if it is present there. Then delete this file from the 'webapp' folder and start again using 'mvn jetty:run'. No more errors, You are good to go now  :) :)


Monday, March 26, 2012

Remote debugging maven jetty with IntelliJ Idea in Ubuntu 11.10

Jetty web server is an open source http server/client container which can be used to run and test webapps.  Jetty server provides a plugin to integrate with apache maven and it can be used to run a webapp in a maven project. To do this we need to add jetty-maven-plugin into our <plugins> section by adding it into webapp pom.xml file.

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.10</version>
            <configuration>
               <webXml>${project.build.directory}/jetty/WEB-INF/web.xml</webXml>
               <webAppConfig>
                  <contextPath>/${webapp.name}</contextPath>
                  <!--enable reloading static resources -->
                  <overrideDescriptor>src/test/resources/override-web.xml</overrideDescriptor>
               </webAppConfig>
               <scanIntervalSeconds>10</scanIntervalSeconds>
            </configuration>
         </plugin>


Now add the following Maven Options line into your .bashrc file.

For JDK 1.3 or above :
export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"

For below JDK 1.3:
export MAVEN_OPTS="-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"

Goto the webapp folder from terminal and enter,
 mvn jetty:run
Jetty server will start on debug mode and will listen on port 8000 now. The following info will be appeared in terminal.




Goto IntelliJ Idea project and create a remote debug confiruation giving following parameters. (to do this follow the path Run --> Edit Configurations. Click on the + button followed by Remote and you will see remote configuration window appears)


Host = localhost
Port = 8000

Run the remote debug and it will also listen on port 8000 now.