Saturday, May 19, 2007

On Running Tomcat Service as Another User

I've always used the Tomcat Service Manager to start/stop tomcat (the little icon in the system tray or notification area of the WinXP taskbar). It's so easy and convenient ... right click the Start Service/Stop Service.

However, I have noticed some weird behavior when web applications deployed to Tomcat use environment variable such as USER_HOME. For instance, when starting OpenMRS, the application needs to get the "user.home" system property in order to load modules, runtime properties, etc from the home directory of the user who started Tomcat.

Because the Tomcat Service Manager starts the Tomcat instance as the LocalSystem user (which doesn't have an actual user account on my machine), it can't find the directory specified by the "user.home" variable. Actually, it usually returns just "Application Data", which causes OpenMRS to look under "c:\Application Data", instead of "c:\Documents and Settings\LocalSystem\Application Data".

Attempt #1
My first thought was to configure Tomcat Service Manager to use a different user when starting up. I opened the Tomcat Service Manager Properties dialog (right click Tomcat > Configure... in the task tray), navigated to the "Log On" tab, and configured Tomcat to run as me. I saved the settings, closed the dialog, and restarted Tomcat.

And ...

Nothing. Same result as before. Even more strange was the fact that sometimes the user.home was "c:\Application Data" and other times it was set to "c:\Documents and Settings\Default User". I wouldn't care if it was one or the other, but the constant switching was causing weird behavior in OpenMRS.

I found the following bug to help explain this behavior.

It looks like the developers are just going to squash this bug (which is fine), but if anyone needs this functionality, let them know.

Attempt #2
My next solution was to create a new user account for the LocalSystem user. I'm still testing this out and will post the results when I get a chance.

I believe you might also be able to specify a username/password using the tomcat5 service commands, but I'll go with a quick fix until that becomes necessary.

Attempt #3
So it turns out that while the Tomcat Service Manager does not implement the "Log On As" feature, the Windows Service does. If you're using Tomcat Service Manager, then you will have an Apache Tomcat or TomcatX (where X=the major version number) service installed. You can check the Log On settings by following these instructions.

1. Click on Start, Control Panel, Administrative Tools then Services.

2. Right click on Apache Tomcat and select Properties.

3. Click on the Log On tab and fill in the authentication details of the Windows user that you want to start Tomcat.

4. Q.E.D

Thursday, May 17, 2007

Eclipse 3.2 extremely slow saving build.xml

Working through an issue on Eclipse 3.2. Everytime I open, edit, and save a build.xml file, Eclipse freezes up for 5 - 10 seconds. Not a huge deal, but it's relatively annoying if you're not in a patient mood (and I hardly ever am). After Google search, I found that this is a known issue for Eclipse 3.2.

And the workaround is relatively simple.

Uncheck "Provide proposals for user defined tasks" under Windows > Preferences > Ant > Editor > Content Assist.

Tuesday, March 20, 2007

Google Summer of Code - OpenMRS Project

In collaboration with Google, the OpenMRS project is proud to offer internship opportunities through the Google Summer of Code program. OpenMRS is a successful open-source project developing an electronic medical record system for developing countries.

Have you ever imagined that writing code could save lives? Then apply to OpenMRS for the Google Summer of Code 2007 and make a difference this summer.

  • Develop software for the developing world
  • Contribute to a major open-source project
  • Learn from experienced open source developers solving real-world problems
  • Earn a summer-long stipend so that you can focus on your work
  • Make a difference in the world by helping in the fight against HIV/AIDS, TB, and Malaria...doing what you enjoy most

This summer, students around the world have the opportunity to participate in an exciting collaboration between OpenMRS ( and Google, Inc. to further develop an open-source medical record system that improves the care of patients with HIV/AIDS, TB, and Malaria. The Google Summer of Code 2007 program provides promising student software developers an opportunity to help these vulnerable populations by spending their summer vacation writing new code that will be used in countries throughout the developing world. During this twelve week program, successful applicants will work directly with assigned mentors to complete their choice of a variety of focused development tasks laid out by the OpenMRS collaborative.

Interested? Visit or for more information. Applications are now being accepted, the deadline for all submissions is March 24th, 2007.