Injecting JNDI datasource from AWS Beanstalk RDS

When deploying web applications that rely on JNDI based datasources to an Amazon webservices beanstalk environment you will soon run into the problem of how to create an JNDI datasource for beanstalks Tomcat instances (because it doesn’t provide one by itself). The method described in this post has the disadvantage that you have to alter your WAR file in order to include the resource definition in your ware file, making your WAR file dependent on the target environment. To avoid repacking my WAR files I slightly altered my approach and came up with the following solution:

I created a ServletContextListener that looks for amazons well known environment variables that are available when you define an RDS (relational database service or in short terms: a database). The AwsRdsMysqlJndiInjector then collects the information for database access, creates a BasicDataSource based datasource and connects it with the JNDI context name given by the environment defined in the beanstalk configuration (which has to match the datasource you defined in your web application.

Lets assume a standard Spring configuration referencing a JNDI datasource:

and a Amazon Beanstalk configuration using a mysql engine based RDS:


To make this RDS available as a JNDI link with the name java:comp/env/jdbc/mangodemo configure the trailing name of the JNDI link as environment variable in your Beanstalk software configuration:


so it looks like this:


the following class will pick up this information an create an accordingly named JNDI link:

as last step add the class as servlet context listener to your web.xml:

Success or error messages should show up in your Tomcats catalina.log. For updates sourcecode see

By |December 22nd, 2014|development|

Functional logging with Mango

To support the everyday need of functional logging a new logging feature was added to Mango. The goal is not to supersede logging via log4j and its companions but to provide functional logging for the application itself.

The logger can easily be injected via spring and can be used in two ways. The first usecase of course is traditional logging if messages with a log level:

a log viewer is provided an can be added to your navigation tree as follows:

Log viewer example


It is also possible to log events that are specific to a single business object, for example an entity:

The above example attaches the log messages to an instance of CountryVO. They can be viewed when showing/editing the said CountryVO using an editor.

Editor log viewer example editor_log_viewer

For more information see the documentation

By |December 8th, 2014|development, mango|

Using Amazon Elastic Beanstalk with JNDI resources

During the migration of the Mango Live Demo from a homegrown salt configuration management based deployment approach to Amazon Elastic Beanstalk I (as many others) came across the problem to provide a JNDI datasource for my web application which isn’t really straightforward in Beanstalk so here is my solution:

First of all, the Tomcat started inside your Beanstalk application has to be configured with a JNDI datasource. Because messing with the /etc/tomcat7/server.xml would risk messing with the Beanstalk configuration I opted for providing a context.xml inside the META-INF folder of my web application (which is extracted anyways to be deployable via git aws.push.

Beanstalk provides environment variables for the configured RDS (Relational Database Service) instance of your Beanstalk application, which can directly be used in the META_INF/context.xml


Now the environment has needs two additional jar files for this to work, for once the Commons DBCP library for managing the DataSource and of course the MySQL Connector/J providing the driver class com.mysql.jdbc.Driver.
The default Beanstalk environments can be customized via special YAML based configuration files, that have to be placed inside the folder .ebextensions. The files can create users, install packages and like in our case, simply create files, so create the file .ebextensions/server-update.config with the following content.


This configuration will download the two needed jar files an place them in the Tomcat 7 lib folder.
To finally active the configuration add the config file:

git add .ebextensions/server-update.config && git commit -am "JNDI configuration"

and deploy everything to Beanstalk as usually:

git aws.push

By |November 30th, 2014|development|

Endless scrolling using GWTs DataGrid

Sometimes when you have to display large amounts of constantly growing, ordered data a simple DataGrid using a pager isn’t enough, because

  • you do not (not even approximately) know how many data you have
  • new data constantly gets added

Imagine looking at a certain timespan of a logfile (red marked area). As you are looking, new log entries are added (on the left side). On the right side there may be thousands of old log entries. Because all log entries are ordered by it’s timestamp it should easily be possible shifting the red area to the left or right.

endless_datagrid1 (1)

To support this usecase I created EndlessDataGrid which is basically a plain DataGrid using a ListDataProvider which represents the actually displayed section of the ordered data. A MouseWheelHandler registered on DataGrids internal ScrollPanel intercepts mousewheel up/down events and dispatches them to a callback handler that can be registered on the EndlessDataGrid. The data grid then calls onPageUp(…) respectively onPageDown(…) when the first/last entry of the table is reached. Due to GWTs asynchronous nature, calls made inside the callbacks methods will almost certainly be asynchronous, so when the calls return with their data they have to call the appropriate methods (pageUpFinished(…), pageDownFinished(…). Because different methods are called when data is returned, the newly arrived data (in the case you scrolled upwards) can visually be marked, so that it is easier to distinguish from already loaded data. Dialing the mousewheel fires a lot of events and to prevent the EndlessDataGrid from hammering your backend, it waits some time before the callback is called again (default is 200ms, can be altered via setCallbackQuietPeriod(int).

Example of newly retrieved entries endless_datagrid1

Usage example

Full sourcecode is available at Github, for a working Demo see (Administration -> Log)

By |November 30th, 2014|development, mango|

Wait a minute Mr. Postman

A new little feature that might come in handy in the context of web application is an easy to use service to send mails. The now provided MailService is a thin layer above Springs mail support using Apache Velocity as template engine.

Example Velocity template

And here is how you would send the mail:

MailService mailService;

Map<String, Object> model = new HashMap<String, Object>();
model.put("name", "Steve");
model.put("link", "");
model.put("username", "steve23");

mailService.sendMail("", "classpath://mailtemplate.vm", model);

For more information see the documentation for the MailService.

By |November 13th, 2014|development, mango|

Mango Documentation

After many unsuccessful attempts to find a decent solution for documenting Mango I finally came to GitBook which not only provides a nice markdown based format plus editor but also integrates well with a CI server and of course GitHub itself.
A good part of the current blog posts is already converted, so have a look at:

By |November 11th, 2014|development, mango|

Mango Changelog 2


New Showcase model providing a more understandable real life example, as well as a greeting popup explaining where to look first

  • 25b159a demo data generator
  • ae356e6 build fix
  • 81edd58 do not run demo data generator in junit tests
  • 862807a removed demo date gen. test
  • 7a9e35f column layout progress
  • a7bc86b demo data generator improvemts for customer creation<
  • b30059f disable mandatory validation for filter controls
  • 8c1885b Merge branch ‘master’ of
  • eb5c3da showcase greeting popup
  • f092d43 inheritance fix for controls pointing to non-datatype
  • Model

    Formatter updates for controls and datatypes.

    • 896caf6 source formatting for controls/dattypes
    • 1d3a35d source formatting for controls/datatypes
    • f4b6548 control model formatter updates


    Simple multicolumn layouts are now supported.


    Can now be model read only, and additionally given a width value (unit is character) that is used for width calculation.

    • 88ae47c text max/min length validation
    • c7e486e width calculation for text controls
    • 665d365 support for readonly control
    • 93a67cd support for control width
By |October 23rd, 2014|development, mango|

Mango showcase refactoring

Looking at the feedback for the showcase introduced in this post the application was a little bit to abstract to understand the generic model concepts. I refactored into an simpler more “real world” example, which is now online at:

By |October 22nd, 2014|development, mango|

Mango Changelog 1

  • 9ea26d8 date picker css fiddeling
    The original GWT datepicker is rather small which makes it hard to hit the right date
  • 1344fd4 pointer cursor for help popup link
    The cursor icon for the control help now is the same as for buttons to show that it needs to be clicked
  • dbc7b92 removed single navigation model root
    The root navigation entry for the showcase was redundant, now fewer clicks are needed to reach the actual navigation entries
  • 4b889b0 integer/decimal/date control
    Examples for date/integer and decimal controls added to the showcase
  • f3805c0 provide visual feedback for editor dirty status
    Visual feedback in form of an asterisk is now provided to show the editors content has changed
  • 1bfdce9 help texts
    Each control now has an optional help text which is used to reveal the defining model for the control in the showcase
By |October 20th, 2014|mango|

Mango Showcase

As Mango slowly progresses towards being usable and some people asked me, I created a showcase that is directly feed from Mangos continuous integration stream. The showcase is actually an application that is contained in Mango itself, mainly to create testcases for all new features that are implemented.
More features will be added over time, currently only a (hopefully working) subset is shown. Because the URL may change from time to time (the server is an dynamically allocated amazon EC2 instance, see this post for technical details) each CI build generates a HTML document leading to the current showcase URL:
Mango Showcase ยป

Showcase Screenshot:

During redeployment, the showcase may be unavailable fort short periods, see the Mango CI build pipeline for the current build state (


By |October 16th, 2014|development, mango|