Thoughts on…

Java Middleware & Systems Management

Archive for April 2009

Jopr 2.2.0 released!

leave a comment »

Jopr 2.2.0 has finally been posted to SourceForge!

I’m happy to say that if you download the bits today, assuming you’ve been a user since it’s initial release, you may very well have trouble recognizing that you’re using the same product as before. Although this release was originally focused on just two items – enhancements to support cluster-oriented views and support for monitoring/managing external Tomcat instances – so much more was accomplished.

As you’ll see below, and as the 2.2 sneak peak clearly revealed, usability inadvertently became a focus of this release – a new menu bar with resource and group search functions, resource and group navigation trees with right-click context menus, and a sticky tabbing infrastructure are just some of the notable enhancements.

I’m especially pleased with the number of performance fixes that made it into this release. These weren’t just constrained to back-end processes or how the agents and servers communicate, but several people have been testing the 2.2.0 BETA and have noted they can feel the difference in the user interface. If there’s any one thing that would frustrate me about using a software product I’d have to say it’s how long I wait between when I click something in the UI and when I receive feedback about that action. So we hope you – the community – appreciate the time we took to improve that part of the overall experience for you.

For those that like details, I’ve again gone through JIRA and scanned the more than 600 issues resolved this release. Below is a summary of all of the noteworthy changes:

UI Enhancements

  • complete rewrite of event history and / monitoring UI pages from struts/tiles to jsf/facelets for resources, groups, and autogroups
  • addition of availability history page for resources
  • addition of xmas tree lights for autogroups and compatible groups
  • improve display of availability and membership counts for groups
  • brand new menu bar to replace old, flat link menu
  • brand new resource and group tree navigation components, with right-click context menu support
  • subsystem views – config updates, operation history, new oob metrics, alert definitions and alert history
  • several other markers/icons added to the overview>timeline page, and fixed it so it works in IE6
  • sticky tabs when navigating between resources and a split pane divider that remembers it’s relative percentage location
  • gave our tabbing infrastructure a facelift, moved from image rollovers to pure css, and are now using a wicked cool gradient
  • revamped resource and group favorites into the menu bar
  • support for recently visited resources and groups in the menu bar
  • auto-complete / search for resources and groups in the menu bar
  • several fixes for ops and alerts pages to improve usability
  • added new resource summary page
  • updated nearly all of our icons across the entire site
  • numerous IE6 and IE7 fixes

Notable Features

  • self-healing agents when they detect they are sick
  • clean up of authorization rules across several pages in the app
  • change to how authz is done – explicit res group denotes membership, while implicit res group is solely for authorization
  • dynagroup querying off of current res availability; also support for parent / grandparent / child context querying
  • support for dynagroup filtering and pivoting off of properties will NULL values
  • auto-recalculation of dynagroups, added some dynagroup “templates” too
  • proper use of XA transactions
  • config change detection + alerting off of that
  • support for aggregate config w/group res config & group plugin config implementations

Plugin Development / Deployment Improvements

  • standalone tomcat and EWS support
  • fix hot deploy of plugins
  • new plugin generator
  • pushed deploy of plugins to DB now, not just filesystem
  • lenient deployment of plugins whose dependency graph is not satisfied

Caching / Performance Tuning

  • fixed paginatedDataTables so they only load once (page-scoped caching)
  • all user preferences cached to the session
  • MICA icon generation scheme doesn’t require DB hits at all – all done via in-memory lookup
  • solved a dozen or so N+1 (or worse) query issues
  • revamped measurement out-of-bounds system
  • fine-grained updates for measurement baseline calculations
  • precompute of current availability for resources
  • replaced resource group SLSB methods with native sql solutions, supporting recursive rules
  • alerts cache rewritten to be near-lockless, and reloading cache doesn’t block readers
  • upgraded quartz library, resolved qrtz_table locking issues
  • using sigar proxy cache
  • async committal of measurement data on postgres
  • events throttling

So download it, try it out, and ping back here or on the Jopr forums if you have any questions.


Written by josephmarques

April 30, 2009 at 1:55 pm

Posted in rhq

Tagged with

Custom JSF/Facelet Exception Handling

with 13 comments

Have you ever used a JSF-based application, navigated to some page, only to see a nasty error?

This is what you get out-of-box with facelets. Most of the time it happens when the facelet tries to resolve some EL expression, needs to create some JSF managed bean, but one or more required URL parameters are either missing or have invalid values.

In a development environment, it makes sense to show this page because the various pieces of contextual information (full stack trace + JSF component tree + variables in scope) provide plenty of clues with which to diagnose the issue. However, when you ship a product to a customer or push your changes to a production environment, it would be nice to change the behavior and provide a pleasant error page to the user.

Fortunately, the facelets framework makes overriding this default behavior incredibly simple. The basic premise is to redirect to a custom error page so you can provide a layout that hides the unappealing stack trace, but which still provides a link to view those details (primarily so your customers can report the bugs back to you).

Note: the following code examples will be pulled directly from the RHQ / Jopr code base.

The first step is to add a custom view handler to your web application. Open up the faces-config.xml file and add a custom view handler:

<faces-config ...>

Then override the default mechanism for dealing with errors that the facelet framework encounters:

public class FaceletRedirectionViewHandler extends FaceletViewHandler {
    protected void handleRenderException(FacesContext context, Exception ex) throws IOException, ELException,
        FacesException {
        try {
            if (context.getViewRoot().getViewId().equals("/rhq/common/error.xhtml")) {
                 * This is to protect from infinite redirects if the error
                 * page itself is updated in the future and has an error
                log.error("Redirected back to ourselves, there must be a problem with the error.xhtml page", ex);

            getSessionMap().put("GLOBAL_RENDER_ERROR", ex);
        } catch (IOException ioe) {
            log.fatal("Could not process redirect to handle application error", ioe);

View full source here

The basic strategy is capture the exception and redirect to your new error page. However, what if there is a compile error on the error page itself? Your new error handling code would capture that error and try to handle it, which would redirect back to the custom error page which still has that error on it! This leads to an infinite redirect, which all modern browsers can and will detect, but it doesn’t provide much useful information as to what error occurred on the page.

You might be asking yourself, “How likely is it that the error page will have an error?” Well, this could happen either as you’re writing the page for the first time, or are updating the page in the future to add other features. Fortunately, there is an easy way of protecting against this. In your error handling code, simply test which JSF viewId you’re coming from and, if it’s your new error page, then revert back to the default handler by calling the superclass method being overridden. Don’t forget to explicitly break/return out of the custom handler, otherwise you’ll still see the infinite recursion.

The next and final step is to write the logic that pulls the exception back out of the session map on the other side of the redirect:

public class GenericErrorUIBean {
    String summary; // the name of the exception class, usually self-descriptive
    String details; // a little more information about the named exception
    List<Tuple> trace; // fine-grained trace details

    public GenericErrorUIBean() {
        trace = new ArrayList<Tuple>();
        Throwable ex = (Exception) getSessionMap().remove("GLOBAL_RENDER_ERROR");

        String message = ex.getLocalizedMessage();
        String stack = StringUtil.getFirstStackTrace(ex);
        trace.add(new Tuple(message, stack));
        while (ex.getCause() != null) {
            ex = ex.getCause();
            message = ex.getLocalizedMessage();
            stack = StringUtil.getFirstStackTrace(ex);
            trace.add(new Tuple(message, stack));

        summary = ex.getClass().getSimpleName();
        details = ex.getMessage();

    private static String getFirstStackTrace(Throwable t) {
        if (t == null) {
            return null;
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        return sw.toString();

View full source here

Depending on what you want your error page to look like, you can use a variety of methods for chopping up the stack trace into more manageable and/or user-friendly bits. In this case, the solution I used for the RHQ platform loops over the full trace one stack frame at a time. At each frame, we record the name of the exception-class and map that to the exception-stack at that frame. In this fashion, we can generate of list of tuples which can be iterated over in our error.xhtml facelet with either the ui:repeat or a4j:repeat tag.

The end result is a page that looks at professional by hiding the ugly errors and showing the root cause in small, easy to understand language.
Note, however, that the page can still be used as a debugging tool. See the “view the stack trace” link at the bottom? Clicking it opens up a modal dialog which display the full stack trace (which is useful for reporting bugs through customer support [for downloaded products], or emailing the webmaster [for hosted applications]).

For brevity, the source code of the error.xhtml facelet has been left out of this blog entry, but you can view the full source here

This is just one of the many solutions employed by the RHQ platform to provide a great web driven interface that centralizes the monitoring and management of your enterprise systems. To find out more, please visit one of the links below:

RHQ (base management platform) –
Jopr (Jboss specific extensions to RHQ) –

Written by josephmarques

April 27, 2009 at 7:29 am

Posted in webdev

Tagged with