Solve webapp random startup errors (connection time out) and slowness

February 16th, 2011

When developping Java web apps, you may sometime see random startup errors like this one :

java.lang.IllegalStateException: Unable to instantiate container.
at org.apache.tiles.web.startup.TilesListener.contextInitialized(TilesListener.java:60)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
(...)

Most of the time your application works, but sometimes it just does not start.

This is because of the dtd resolution mecanism: if you use the reference of a dtd which is not in the webapp classpath, the container will try to get it from internet.

If the remote site is down (in this case http://tiles.apache.org), your app will no longer start.

Sadly, it’s easy to get in this situation.

  • Upgrade a library without updating xml headers
  • Copy/Paste a snippet from the elsewhere

… and the container will start to fetch dtds from the internet.

In my case, the previous error was caused by :

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">

<tiles-definitions>
(...)
</tiles-definitions>

instead of :

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
(...)
</tiles-definitions>

With tiles 2.0.6 in the classpath.

Conclusion
Be sure to use the exact version of the dtd in your classpath. Don’t pickup examples from the internet without double-checking the dtd.
This will prevent longer startup times and potential random errors.

Note: this post dedicated to Olivier and Jimmy :-)

Scheduled outage (updated)

January 8th, 2011

This blog will be offline for a few days/weeks. Moving server and getting a new Internet connection.

See you soon :-)

In the mean time, please use google cache.

UPDATED : This blog is back online. :-)

ESIGate Tutorial – Partie 2

December 16th, 2010

Après une première partie technique, nous allons étudier une partie plus théorique sur les différents usages d’ESIGate dans des projets Web.

Attention: Article en cours de rédaction, les concepts étant relativement complexes à comprendre (mais simples à mettre en oeuvre), vous êtes invités à commenter ce post pour aider à l’améliorer.

Le coeur d’ESIGate est une implémentation Java d’un moteur d’ESI :

  • a partir d’un document HTML, le framework va parser le flux à la recherche de directives référençant des contenus à intégrer depuis des URL externes.
  • Ces contenus sont récupérés et mis en cache automatiquement, puis insérés dans le flux HTML original.
  • Les directives peuvent soit suivre la norme ESI, soit utiliser le format ESIGate, plus riche en terme de fonctionnalités.

ESI, à quoi ça sert ?
Les usages sont multiples, mais à l’origine la norme ESI permet d’étendre les possibilités de mise en cache des pages produites par des applications web et donc d’améliorer grandement leurs performances.

Continue Reading »

ESIGate Tutorial – Part 1

November 28th, 2010

(Ce tutorial est aussi disponible en Français : ESIGate Tutorial – Partie 1)

In this series, I will present the various uses of ESIGate framework (former Assembly Web Tool – WAT).

In Part 1, we will integrate a very simple application in a remote template, only via http. The typical use is a corporate intranet: multiple different applications (content management, HR management, time reporting, etc …) can use the same theme, based on a master application.

This has the following benefits:

  • almost no need to work on styling (html/css) in slave applications.
  • When the theme changes in the master application, the changes are immediately reflected on all slave applications without restart
  • the master application can be replaced with no impact if the new theme is compatible
  • If the new master application is incompatible with the previous theme, the synchronization can be ‘broken’ by pointing slave applications on a static html file

Continue Reading »

Git : set committer name and email

November 28th, 2010

git config --global user.name "<your-name>"
git config --global user.email "<your-email>"