The Holy Java

Building the right thing, building it right, fast

Posts Tagged ‘exception’

Tip: Include Context And Propose Solutions In Your Error Messages

Posted by Jakub Holý on May 23, 2013

A Puppet run has failed with an error message like this:

“No matching selector for ‘prod’ at some_puppet_file.pp:31″

If you know puppet well enough, you will immediatelly know what is wrong and how to fix it. But what if you don’t know what a ‘selector’ is? Interpreting error messages is often hard without deep knowledge of the software. Be nice to the users / fellow programmers, do not expect they know everything, and include helpful context and preferably also suggest some possible solutions. If the message read instead:

“No matching selector for ‘prod’ at some_puppet_file.pp:31; the available selectors are ‘production’, ‘test’, ‘staging’; have you forgotten to add ‘prod’ or default?”

wouldn’t it be much more clear and helpful?

Posted in General | Tagged: , | Comments Off

Exposing a POJO as a JMX MBean easily with Spring

Posted by Jakub Holý on September 16, 2010

JMX is a great way to check or change state variables or invoke a method in a (remote) running application via a management GUI such as JConsole. And Spring makes it trivial to expose any POJO as a JMX MBean with only little configuration in a few minutes. The Spring JMX documentation is very good, however there are few points that I struggled with for a while and would therefore like to record here the right solutions.

I needed to monitor a command-line java application using Spring 2.5 on IBM JVM 1.4 1.5 running on a server with a jconsole on Sun JVM 1.6 as the JMX client on my PC.

Read the rest of this entry »

Posted in Languages | Tagged: , , , , , | 1 Comment »