Thursday, July 09, 2009

Tip: How to easily reorder bullet points in MS Word

A quick tip on a discovery I just made: You can quickly reorder bullet points in Microsoft Word putting the caret in the bulleted item to be reordered (i.e. click on the item), and then use Alt+Shift+UpArrow or Alt+Shift+DownArrow to reorder the selected item within the list of bullet points.  Apparently this works in other MS Office programs as well (such as PowerPoint).

I’ve found that this works a lot more nicely than cutting the item to be moved, and then pasting the item in the new location in the list (since often, line breaks need to be fixed up after the new item is pasted in.)

Bonus tip: Alt+Shift+LeftArrow and Alt+Shift+RightArrow will indent/unindent the selected bulleted item.

Thursday, July 02, 2009

Installing m2eclipse in Eclipse 3.5

After newly installing Eclipse 3.5 (replacing my old Eclipse 3.3 install), when I tried to view a document with a Maven pom.xml file that I’d previously had open in my workspace, I got an error:

Could not open the editor: No editor descriptor for id org.maven.ide.eclipse.editor.MavenPomEditor

The fix was to install m2eclipse (the Maven plugin for Eclipse). I did this in Eclipse 3.5 as follows:

  • Help | Install New Software
  • In the "Install" dialog: click the Add button
  • In the "Add Site" dialog:
    • Name: m2eclipse
    • Location: http://m2eclipse.sonatype.org/update/
  • Click OK
  • Back in the "Install" dialog, in the "Add Site" dropdown, select: m2eclipse
  • Under "Maven Integration", I checked:
    • "Maven Integration for Eclipse (Required)"
    • "Maven POM Editor (Optional)"
    • "Maven POM XML Editor (Optional)"
  • Click Next, go through and complete the Install wizard.
  • When prompted, I restarted Eclipse.

That got my Maven POM editor up and running in Eclipse 3.5.

Monday, June 22, 2009

Multiple Displays: The future of TV & gaming?

I’ve been running three monitors on my PC at work for a while now, and it’s been working great for me.  Multiple monitors works great for running business applications and/or doing software development; for example, I typically run my programming environment maximized on my primary monitor, run most the programming environment’s secondary windows (e.g. project file list, search results, list of compiler warnings/errors, etc.) on the second monitor, and the application’s UI or other reference material on the third monitor.  I’m able to see everything I need to see at once without shuffling windows around.

PC Games

As multiple monitors on PCs continue to gain more market penetration, it would be nice to see more PC games join business applications and take advantage of the potential availability of multiple displays.  A game’s main view of the game world could go on the primary monitor, and secondary information could go on a second monitor, freeing the entire screen area of the primary monitor to show the game world.  For example:

  • In MMORPGs such as World of Warcraft, the display can become pretty “cluttered” with ability toolbars, party status display, mini-map/radar, active buffs/debuffs, and more.  All of that could (optionally) be moved onto a secondary monitor, freeing the entire area of the primary monitor to show the game world.
  • In RTS games such as the classic Starcraft, the selected unit(s) and their information, “order” buttons (move, attack, stop, etc.), and mini-map could be moved onto the second monitor.
  • In traditional RPGs, secondary data such as inventory screens, skill/spell lists, character statistics display, and so forth could be shown on the second monitor, again freeing the entire area of the primary monitor to show the game world at all times.

Console Games

It would also be nice if future console systems (i.e. successors of the current generation’s Wii, Xbox 360, and Playstation 3) would (optionally) support hook-up to multiple television sets in the future.  In addition to the getting the same benefits that would be realized by PC games, this might also help with situations where there are multiple players playing simultaneously on the same local console system. 

Today, local multiplayer is typically accomplished via split screen; in the future, one or more players’ view could be moved onto the second screen.  If a future Rock Band or Guitar Hero game supported the addition of a keyboard (piano) part or otherwise supported more players playing together beyond the 4 supported today, multiple TVs could help with the problem that would otherwise be encountered in trying to squeeze 5+ players’ parts onto the same screen!

Handheld Games

Obviously, the one gaming system that is way out ahead of the curve as far as multiple monitor support goes is the Nintendo DS.  With two screens built into the hardware, all games on the platform can be designed to fully take advantage of the availability of two screens. 

Although I don’t own a DS, I’ve had a chance to briefly borrow one owned by my nephews on a couple of occasions.  It is really cool in a game like Zelda to be able to see both the primary game world and the overhead map view (while in a dungeon) at all times.

TV - Sports

Multiple screen support would also be really cool in the future for TV – particularly for sports broadcasts.  In my case, I’m a big fan of Michigan Football.  Instead of watching games on just a single screen (where the display tends to focus in on the quarterback or whomever has the ball, to the exclusion of the rest of the field), it would be amazing to have a second screen showing what the downfield receivers are doing (or other action away from the ball appropriate to the play), and a third screen dedicated to showing real-time stats at all times.  The score and “ticker” could also be shown on the third screen, freeing the entire area of the main screen to show the game action.

Obviously, support for people watching the game on just a single TV (I’d likely be among them, at least for now!) would have to be maintained as well.  Perhaps an “all in one” game broadcast (essentially what we have today) could be carried on a particular channel; the “multiple screens” version of the game could be carried on a separate set of channels.

This kind of multiple screen support for sports broadcasts, particularly combined with support for single-TV viewers, would work out to quite a few channels being dedicated to sports broadcasts!  Still, with the proliferation of channels available even today via digital cable or satellite broadcasts, this kind of thing might be possible in the not-too-far future.

Put those old displays to use!

This would also give people something to do with “old” PC monitors and TVs as they gradually get replaced over time with HD versions: Put the old displays to good use as secondary information displays for games and TV!  One of the 3 monitors that I have at work is an old monitor that would be sitting on a shelf at home (or worse, in a landfill somewhere) if I didn’t have a use for it as the third monitor on my work machine.

So, PC game developers, console hardware companies, and sports broadcasters: Go forth and make it so.  :-)

Monday, June 01, 2009

PC Frequently Rebooting due to Power Supply Unit Issue

This past Saturday, I was having lunch with the family in the kitchen when I heard from the office the sound effect that my new PC plays after booting.  I thought that was odd (since no one was in there using the PC), but shrugged and figured that maybe the PC had rebooted itself due to some automatic update?  When I heard the same sound again a few minutes later, though – indicating a second reboot in the span of a few minutes, with no one sitting at the machine – I investigated.

As I worked on the PC, I found that it was rebooting itself every few minutes, at irregular intervals.  The PC had never done this before; aside from some heat-related bluescreen issues after I first put the PC together, the PC had been quite stable for the 6 months or so since it was built.  I had the reboot problem reproduce once while I was in the boot-time BIOS configuration utility, which proved the problem wasn’t a Windows issue.

Due to the intermittent nature of the problem, I initially suspected it might be caused by another overheating issue.  However, the BIOS configuration utility showed that the CPU was operating at a nice and cool (relatively speaking!) 40 degrees C or so. 

I also suspected a possible RAM issue – perhaps one of the four RAM modules had gone bad and was causing the reboots.  However, I tried removing two of the RAM modules at a time (with the machine powered off, of course); the spontaneous reboot reproduced with only modules #1 and 2 in the machine, and also with only modules 3 and 4 in the machine, which appeared to rule out a memory module issue.

Finally, though, I got “lucky” in my investigation.  After the machine rebooted itself twice in rapid succession, I manually toggled off the power switch at the back of the PC’s power supply unit (PSU) to keep the machine off while I (once again) manually inspected the machine’s hardware.  When I toggled the power supply unit switch back on, I got a surprise – a bright spark and a loud “POP” sound from within the power supply unit!  I immediately pulled the power cord out of the PC to prevent anything further from occurring with the PSU.

This seemed unlikely to be a coincidence.  If the PSU had indeed gone bad somehow, I could see that the behavior of the system rebooting (with no error message, except Windows complaining that it hadn’t been shut down properly at restart time) would be consistent with the system losing power momentarily, and then getting it back immediately afterwards.  I was fairly confident that the incoming power supply to the machine was OK, as I had the machine hooked up to power via a UPS (an uninterruptable power supply -- designed to ensure a consistent flow of power, even in the event of a power failure).

I replaced the apparently faulty power supply unit with a spare that my father-in-law Doug had on hand (thanks Dad K.!) – and that resolved the issue!  The machine has been running since Saturday afternoon with no problems.  So the intermittent spontaneous reboot problem had been caused by a faulty power supply unit. 

I wrote “BAD” on the faulty PSU and threw it away.  I also ordered a modern 500W PSU with integrated PCI-Express and 8-pin CPU connectors to replace the one I’m borrowing from my father-in-law.

The lesson learned here for me is not to cheap out on buying a PSU when building a new PC!  When selecting a case and power supply for this machine, I’d mostly paid attention to cases, and had just accepted the included power supply that came with the case – for the PSU, I had only really looked at the raw wattage on the PSU (450W).  The PSU had turned out to be an older/cheaper model with no PCIe connection, and only one SCSI drive connection.  For this PC, with reasonably demanding power requirements (including a GeForce 9800 PCIe video card), the lower-end power supply that came with the case apparently just wasn’t sufficient over the long term.

In the future when building PCs, I’ll most likely opt for purchasing the case and power supply unit separately, and will certainly pay more attention to the detailed specs of the PSU to ensure that it is likely to be sufficient for the needs of the system I’m building!

Tuesday, May 19, 2009

Fix: Spring-based JNDI lookup can't see .properties file

After refactoring one of our internal applications at work to use Spring XML configuration file based JNDI lookup today, several of the application's unit tests which involve testing of JNDI lookups started failing. The following error appeared for each failed test in the jUnit XML log file:

<error message="Error creating bean with name '[dsName]':
Invocation of init method failed; nested exception is
  javax.naming.NoInitialContextException: Need to specify class name in
  environment or system property, or as an applet parameter, or in an
  application resource file:  java.naming.factory.initial"
type="org.springframework.beans.factory.BeanCreationException">
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
  .initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
  .doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
... (snipped for brevity) ...
at org.springframework.context.support.ClassPathXmlApplicationContext
  .<init>(ClassPathXmlApplicationContext.java:83)
at [internal namespace].util.TestUtil.getSpringContext(TestUtil.java:167)

Cause

We discovered that the cause of the problem in our case was that, as the error message indicated, Spring wasn't seeing a .properties file present in the project which set a value for the java.naming.factory.initial property.

The line in our Spring context .xml file looked like:

<jee:jndi-lookup id="[dsName]" jndi-name="jdbc/[dsPath]/[dsName]"
  expected-type="javax.sql.DataSource" />

The line in our .properties file (which Spring wasn't finding properly), which set the naming factory class to a class provided by our J2EE application server (WebLogic), was:

java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory

The .properties file was located in the same folder as the Spring context .xml file.

Solution

In the Spring context .xml file, just prior to the jee:jndi-lookup tag, we added a bean of type PropertiesFactoryBean to act as a pointer to the .properties file:

<bean id="jdbcConfiguration"
  class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="location" value="classpath:productInquiry.properties"/>
</bean>

Then, we added a reference to that new bean to the existing jee:jndi-lookup tag (the added part is bolded):

<jee:jndi-lookup id="ot1ds" jndi-name="jdbc/[dspath]/[dsname]"
  expected-type="javax.sql.DataSource" environment-ref="jdbcConfiguration"/>

This change fixed the problem, and got our tests to run successfully.

I hope this is helpful to someone!

Wednesday, February 25, 2009

Getting JAX-WS to work with WebLogic 9.2

I spent several hours at work today troubleshooting problems related to getting JAX-WS (as included with Apache CXF) working in a Java web application running under BEA (Oracle) WebLogic 9.2.  This post contains a summary of the errors I encountered, and their resolutions -- hopefully this will save someone some of the troubleshooting time that I spent today.

Background

Some brief background: I was building some new SOAP web service integrations into one of our internal Java applications, which runs on WebLogic server.  This application was the client side of the integration.  I used Spring, Apache CXF, and JAX-WS to build the integrations.

I first coded the SOAP integrations into a simple stand-alone Java application, and that worked fine.  However, when I plugged my code and the CXF .jar files into the "real" application running on my local WebLogic server, I ran into a couple of errors.

Error #1: "java.lang.NoSuchMethodError: javax.jws.WebMethod.exclude"

Upon running my application under WebLogic 9.2, I got this error in the WebLogic server log file:

org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'internalBeanName': Instantiation of bean failed;
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:
Factory method [public java.lang.Object org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create()]
threw exception; nested exception is java.lang.NoSuchMethodError: javax.jws.WebMethod.exclude()Z

This error turned out to be caused by the fact that in addition to the javax.jws.WebMethod class included in the geronimo-ws-metadata_2.0_spec-1.1.2.jar file included in the distribution of CXF that I downloaded, another (apparently older) implementation of that class is also included in the weblogic.jar file included with WebLogic 9.2.  WebLogic by default assigned priority to classes from its own weblogic.jar file over classes included with my application; as a result, WebLogic tried to use the older implementation of the javax.jws.WebMethod class, which does not include the exclude() method, and the NoSuchMethodError occurred when the other JAX-WS code tried to access that method.

To fix this, I modified my weblogic.xml and weblogic-application.xml files, to instruct WebLogic to give priority to the JAX-WS implementation in my own supplied .jar files rather than its own JAX-WS implementation. 

In my weblogic.xml, I added:

<container-descriptor>
  <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

For more on this weblogic.xml change, see documentation on a similar issue affecting Apache Axis.

In my weblogic-application.xml, I added:

<prefer-application-packages>
    <package-name>org.apache.xerces.*</package-name>
    <package-name>javax.jws.*</package-name>
</prefer-application-packages>

For more on this weblogic-application.xml change, see the WebLogic configuration documentation in the CXF documentation.

Error #2: "Your JAXP provider [...] does not support XML Schema"

Having resolved the NoSuchMethodError, I re-deployed my application, and got this error upon running the app:

org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from class path resource [mySpringContext.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@nnnnnnn] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.

The problem here was that there was an an old (2003) xerces.jar file present in my Java project, which contained an old JAXP provider class which did not support XSD. 

To fix this, I deleted the old xerces.jar file, and redeployed the project.  (I also needed to delete WebLogic's cache, located on my machine at \bea\user_projects\domains\mydomain\servers\myserver\tmp, to completely get rid of the old cached xerces.jar file.)

Wednesday, February 11, 2009

Still Key Jammin', 19 years later!

I was just re-reading a piece of code that I'd written earlier today which attempts to detect duplicate customer records in a particular database table, when I came across a misspelling in a comment: I'd misspelled the word "duplicate" as "dupliate."  I corrected the typo, and continued reading, when I came across another instance of the same misspelling: "dupliate" instead of "duplicate." 

Curious now, I did a search of the source file for other instances of the misspelled word "dupliate"; to my surprise, I found a LOT of instances of that misspelling (all in my own hand-entered comments, so not due to intellisense or copy-paste)!  At this point, I suspected that the problem was due to some factor beyond simple human error, so as an experiment, I tried just typing the word "duplicate" several times in a row (and paying attention to be sure that I actually was hitting the C key).  This was the output:

dupliate dupliate dupliate dupliate dupliate duplicate dupliate

The problem was reproducible almost every time.  I briefly experimented further:

  • The problem WAS reproducible in text editors other than my IDE (Eclipse). 
  • The problem was NOT reproducible when I typed slowly and deliberately, being sure to hit each individual key one at a time.
  • The problem was NOT reproducible using my machine's built-in keyboard (an IBM/Lenovo Thinkpad T60 laptop); only when using the external keyboard (a "standard" qwerty / U.S. layout black Dell-branded PS/2 keyboard, part number 04N454).

I discovered that the specific problem was that while the L and I keys on the keyboard were being pressed, presses of the C key would be dropped/ignored.  I found that every other letter key on the keyboard worked with L and I held down; just not C!

So what was happening here was that in typing "duplicate," I apparently was typing the C (with my left hand) before I'd let go of the L and I keys (with my right hand) -- or at least before the L and I keys had "popped back up" -- and consequently, the C key press was getting dropped.

Now that I'd realized what was going on, I remembered that this is a typical hardware limitation of keyboards: certain keys cannot be pressed in combination with one another.  I hadn't thought about this in years and years -- since back when I used to play 2-player games on the PC that would have both players using the keyboard on the same PC simultaneously.  The old (1990) PC game Star Control actually came with a utility called "Key Jamming" for working around this very issue: The utility would allow you to experimentally hold down various key combinations, and tell you which ones the PC could "see," to allow you to customize the game's keyboard controls on your machine's keyboard such that players in a two-player game wouldn't end up "locking out" one another.

It's unfortunate that the Dell 04N454 keyboard has this particular limitation.  I'm not sure what I can do to work around it, though, short of just needing to have extra awareness of my spelling (particularly in non-spell-checked environments such as IDEs) -- or else looking into using a different keyboard which isn't affected by this particular limitation!