jee

Monitoring JBoss AS start with JMX

Friday, September 3rd, 2010 | Java, Tech-savvy | 2 Comments

Today a fellow colleague asked for a better way to check whether an app server is really up and running than grepping the log file. Well, for we are using a JEE compliant server (JBoss) I suggested looking into JMX for it is the designated monitoring interface, right? Unfortunately I didn’t get replied to even after suggesting it twice. Whatever, apart from proving brilliant communication skills I may have missed something that didn’t make JMX an option (like a firewall issue or something).

Still, I wanted to look into it anyway, because it seemed a fun and pretty simple task to write a little JMX client that probes the desired MBean. But it is even easier. JBoss offers a little helper out of the box that is up to the task in no time. It’s a little tool called twiddle. Usage is self explanatory:

A JMX client to 'twiddle' with a remote JBoss server.
 
usage: twiddle [options] <command> [command_arguments]
 
options:
    -h, --help                Show this help message
        --help-commands       Show a list of commands
    -H=<command>              Show command specific help
    -c=command.properties     Specify the command.properties file to use
    -D<name>[=<value>]        Set a system property
    --                        Stop processing options
    -s, --server=<url>        The JNDI URL of the remote server
    -a, --adapter=<name>      The JNDI name of the RMI adapter to use
    -u, --user=<name>         Specify the username for authentication
    -p, --password=<name>     Specify the password for authentication
    -q, --quiet               Be somewhat more quiet

Now you only have to decide which MBean to probe. As “are u there” is one of the most basic thinks to ask for this isn’t too hard either:

twiddle.sh get jboss.system:type=Server Started

As soon as this returns true the server is up and running.

So, just put this command in your shell script and you can easily probe your JBoss AS if it is ready to go app serving.

Tags: , , ,

SpringSource Certified Spring Professional

Friday, July 24th, 2009 | Certification, Java | No Comments

cert_spring_proAs of today I am a SpringSource Certified Spring Professional. I am totally happy that I made it, this was one of the most challenging certifications I ever achieved (okay, the Certified JBoss Developer was even harder, but it is “open book”).

I can’t go into the details right now (and I am not allowed to) because I have some friends over for a beer. Just one thing:  JavaBlackBelt provides a great summary of the topics that will be in the exam. The Spring Reference Documentation is just awesome and will give you all the information that you need. It is a lot of information, but it’s worth the effort. Okay, gotta go partying :)

Tags: ,

meet the experts @ codecentric

Sunday, June 28th, 2009 | Java, Reviews, Tech-savvy | No Comments

“meet the experts” – that is the title of a great series of small highly specialized conferences organized by my company codecentric. The goal is to bring together experts to share their knowledge and experience, followed by a so called open space, where everybody can start discussion groups about a related topic – experts included. Share your thoughts with the guys who are the top notch players – you don’t get a chance like that at a “normal” conference.

The first event (focus on performance) is over and it was great! My colleague Rob was faster than me in writing his review and I basically share his experiences (Kirk Pepperdine talks on performance and his history lessons on “community driven” eclipse as well as Toplink vs. Hibernate, Heinz Kabutz talks about performance as well, Crete and why he refused to play Guitar Hero, Alois Reitbauer talks about the Titanic from a software development POV and assures the audience a few times “This is not a sales presentation”). So go on and read Rob’s blog post about the event. More are to come, so make sure you keep any eye on the meet the experts web site and join in for one of the next sessions, they sure will be great experiences as well. The next event will be about agile software development, which will be a topic with highly esoteric open space sessions to come. I am really looking forward to this event and share my experience with other pros.

Last but not least: catering was first class and the event went on till late with not everybody going home sober. A great event off the beaten track! Thank you, codecentric.

Check out the slideshow at flickr!

Tags: , , ,

San Francisco – JavaOne 2009 and surrounding areas

Wednesday, June 10th, 2009 | Java, Misc | No Comments

JavaOne 2009 is over and after meeting up with some fellow co-workers from a codecentric partner (dynaTrace – Hi to Andreas and Alois! We had an awesome time together :) ) we decided to team up and explore the San Francisco area together. We’ve been to the north (Sonoma, Napa) and south (Half Moon Bay west coast till Santa Cruz). Enjoy the ride!

Tags: , , , ,

San Francisco – where is that frickin’ bridge?

Tuesday, June 2nd, 2009 | Java, Misc, Tech-savvy | 1 Comment

Tags: , , , , ,

San Francisco – first impreshunz

Sunday, May 31st, 2009 | Java, Tech-savvy | 2 Comments

Touchdown! Despite all my concerncs the journey to the US was all pleasant! The people are friendly and everybody seems to be quite relaxed so far. Enjoy a couple of shots from the first day abroad:

Bikers protest against cars in central city

Tags: , , , ,

Devoxx / Antwerp impreshunz

Saturday, December 20th, 2008 | Java, Misc, Tech-savvy | No Comments

Just recently my company sent me to Antwerp to attend the Devoxx (formerly known as JavaPolis) conference, one of the biggest and best European events for all things Java. Since 2004 I have been trying to take part for two reasons: Top notch speeches and a beautiful city, most notably during winter time. It’s wonderful to go shopping (hmmm, Belgian chocolates) in Antwerp’s historic centre, with everything illuminated, a little bit of snow (if you are lucky) and a good meal (check out the Ultimatum! Lounge like, but with good yet expensive food) at the end of a long conference day.

Roberto Chinnici on Java EE 6

The Devoxx mascot - Human Beat Box anybody?

I hope that I’ll be lucky enough to go there again in 2009.

Tags: , , , , ,

smart way to use the (evil) singleton pattern

Wednesday, November 19th, 2008 | Java | 2 Comments

The usage of singletons is one of the well known GoF design patterns and it’s been said that it’s evil for various reasons (unit testing is difficult, can’t be reused, etc. just google it).

Well, I’ve been ending up with a singleton in one of my apps lately and came across a (German only) hint concerning how to implement the singleton pattern in a smart way. I’ll try to wrap it up in the next couple of lines:

Basic way to create a singleton: make the constructor private and provide a getInstance()-method (please forgive me for not using proper Javadoc, this should stay readable in a blog post, right?):

public class EasySingleton {
 
	// the instance field
	private static EasySingleton instance;
 
	// private constructor
	private EasySingleton() {}
 
	// returns the one and only instance of the class
	public EasySingleton getInstance() {
		if (EasySingleton.instance == null) {
			instance = new EasySingleton();
		}
		return instance;
	}
}

There is one big concern using the pattern this way: it is not thread-safe. Two threads could call getInstance() simultaneously (resp. the instance not yet fully initialized), each successfully testing the current instance for being null ending up with two instances of the EasySingleton object. Bad!

To prevent this synchronize the getInstance()-method:

public class SynchronizedSingleton {
 
	// the instance field
	private static SynchronizedSingleton instance;
 
	// private constructor
	private SynchronizedSingleton() {}
 
	// returns the one and only instance of the class
	// synchronized thus thread-safe
	public synchronized SynchronizedSingleton getInstance() {
		if (SynchronizedSingleton.instance == null) {
			instance = new SynchronizedSingleton();
		}
		return instance;
	}
}

This solves the problem of the singleton not being thread-safe. The let down is the synchronized method only being accessed by one thread at a time, all other getInstance() calls have to wait for the current one to finish. This can easily become a bottleneck in a production environment. Bad.

Now for the smart thread-safe solution:

public class SmartSingleton {
 
	// private constructor
	private SmartSingleton() {}
 
	// returns the one and only instance asking a static final
	// inner class thus thread safe and implicitly synchronized
	public static SmartSingleton getInstance() {
		return InstanceHolder.INSTANCE;
	}
 
	// inner class that provides access to a single instance
	private static final class InstanceHolder {
		// implicitly synchronized by the ClassLoader
		static final SmartSingleton INSTANCE = new SmartSingleton();
	}
}

The private constructor is being called upon the first call to the inner class, whose members are implicitly synchronized by the ClassLoader upon initialization (which is happening exactly once, @see Java Language Specification).

You end up with a thread-safe non-blocking singleton. Pretty cool, eh?

Tags: , , ,

Search

Categories