Tuesday, July 15, 2008

On Losing Internet (and Insanity) After a Standby

So I've got a Lenovo T60p running Windows XP. Every time I bring the laptop out of standby mode the wireless device stops working. The issue manifests itself in a "No wireless connections available" error reported from the Wireless Network Connection wizard. I'm sure this happens on other platforms, but I've only ever seen it with the Atheros wifi drivers on the Lenovo T60p (Atheros 11a/b/g/n Wireless LAN Mini-PCI Express Adapter).

Anyway, it appears to be a bug in how the driver handles power saving. I think such thoughts because by disabling the power-save mode of the driver, the issue goes away.

So how does one disable power save mode on their wifi driver.

1. Right-click My Network Places, select Properties.
2. Richt click Wireless Network Connection.
3. In the General tab, click on the Configure... button.
4. Select the Advanced tab
5. Choose Power Save Mode from the Property field.
6. Select Off for the Value.

I just upgraded to the Atheros 7.4.2.105 driver, so I'm going to need to test Standby mode again with Power Save Mode set to Maximum.

On OutOfMemoryErrors In JUnit Tests

I ran into an OutOfMemoryError while running a JUnit test in Eclipse. OutOfMemoryErrors are usually really simple to fix ... just increase the amount of memory to the JVM. This issue was a little try

So first of all, I figured JUnit would be running inside the Eclipse JVM, so I increased the memory settings in eclipse.ini to 1 Gig (from 512m).

-vmargs
-Xms1024m
-Xmx1024m
-XX:PermSize=256m
-XX:MaxPermSize=256m

I restarted Eclipse and reran the JUnit test. Same result.

I then decided to try to execute the same code in our webapp (running in Tomcat 5.5 configured with 512m of heap) and it completed successfully. This made me realize that the JUnit tests must be running in a separate JVM (either spawned or forked). The critical piece is that the JUnit JVM was not using the Eclipse memory settings from eclipse.ini. Instead, it must be using the default JVM memory settings (i.e. 64m). I searched a bit for how one might allocate more memory to a JUnit test in Eclipse and didn't find anything conclusive, so I went in and played around with the JUnit settings myself.

I started by opening up the Eclipse page that allows a user to manage JUnit configuration settings (right click a JUnit class file and select Run As > Open Run Dialog). From this dialog, click on the "Arguments" tab and paste the following settings into the "VM arguments" field:

-Xms512m
-Xmx512m

Apply the settings and Close the dialog. Rerun your test and reconfigure these settings if necessary.



Tuesday, March 4, 2008

MySQL Conference 2008 (April 14 - 17)

Fellow OpenMRS Developer, Ben Wolfe, and I will be attending the 2008 MySQL Conference in Santa Clara this April 14 - 17. If there are any OpenMRS followers out there who'd like to come by, hang out, talk, or not talk, we'll be in the DotOrg Pavillion from Monday thru Thursday, pretty much all day, every day. Looking forward to seeing you all there.

For more information, check out the O'Reilly conference website.

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.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38516

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.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=125117

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 (http://openmrs.org) 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 http://soc2007.openmrs.org or http://code.google.com/soc for more information. Applications are now being accepted, the deadline for all submissions is March 24th, 2007.