Category Archives: Uncategorized

Bye bye, Hello RBlog!

EDIT: since OpenShift v2 closed with no real migration to its v3 my blog is now hosted at Metawerx:

For the impatients: go to my new blog on .

Blogging is probably the easiest way to share some tips and experiences. But – not to offend anyone – it needs a technical solution adapted to the writer(s).

I started blogging in 2012 on this blog which is an awesome platform ! Everything is already set up : hosting and installation are managed for you.

However, since few months, I felt quite limited relying on the free wordpress platform.

The main issue on is that you can not freely customize/design your blog (theme, plugins, …). Part of that, I often share codes and the provided themes didn’t support snippets very well. And that was embarrassing.

Second, I’m mainly writing about Java but I’m doing it on a PHP platform ! So I felt like promoting something I don’t use myself. It doesn’t respect “eat your own dogfood” principle and I started to feel inconsistent about that.

So I decided to move away from the platform to a more appropriate one.

Then the question was: where to move and what solution to choose ?

Studied options were:

  • custom wordpress or CMS hosting
  • custom application

Custom CMS

Most of the CMS I evaluated (wordpress, drupal, joomla…) were based on PHP technology. This is not an issue by itself but now I want to be consistent with what I’m writing and therefore I decided not to go with a non-Java solution.

To go even further I desired a EE (or at least JAX-RS) based solution but I didn’t find any major open sourced one.

Custom Application

After all, a blog is not that complicated:

  • users
  • category or tag
  • and of course…. content !

So writing it can make sense.

Wait ! No comments ? Yes, after few years of blogging, I realized that it is great to leave a comment directly. But it also prevents the discussion (and often the issue) from being solved in the project list. That’s why I decided to not implement comments. However, it doesn’t mean you can not discuss about a post ! You can of course contact me through my twitter account, or through the project’s mailing-list related to the post, if accurate.

In current blogging sphere, the generated sites have good vibes but I didn’t want to go that way because it requires re-deployment for content updates, and I want to be able to share the content management with non-technical people.

To simplify, it means being able to edit, refresh and get the updates. This means I need a more classical HTTP application.

As mentioned above, the backend decision was to be JAX-RS based solution. Goal is to be able to extend the views in the future and easily write clients (including a CLI).

We have the “backend front” choice, but what about the persistence?

Using JavaEE, I have JPA built-in and it is often used for blogs so it can be a good candidate. But in 2016,there are other options:

  • NoSQL : OrientDB, MongoDB, Cassandra are good candidates for instance
  • Git(hub) : yeah, flat files and a java git client to handle CRUD operations

Here, I decided to use JPA (a relational database more than JPA actually) because it is easier to work with and integrate a RDBMS than other databases today:

  • A default datasource is provided by JavaEE (or TomEE for pre JavaEE 7 versions) and therefore allows you to run without any addition
  • Most of hosting providers (cloud or not) will support it, but maybe not other solutions
  • Git (or Github) was either a custom git repository I didn’t want to maintain (backup etc…) but private hosting was not free. Side note: not using private hosting means your blog (and even your sources) will likely be read on github itself. That means you have no way to view statistics, etc…

I will not detail more the backend implementation, even if some parts are interesting. But I will probably do in other posts. The goal of this post is just to share the other all decision.

So now we have the backend. The frontend choice was the last missing step. Choices were either to use a server framework (like JSF, Tapestry, Wicket…) or a client framework/library (yes I mean javascript). Since JAX-RS choice was there, and that most of the time web server frameworks just wrap what the browser sees, ie javascript, then I decided to go with javascript. It may sound like a geek choice to go lower level, but actually, it is not. In fact, java libraries often try to hide frontend behind Java API. It is rarely up to date and often hard/costly to upgrade a javascript component. I just didn’t want that constraint.

Thus, I decided to fully implement the blog with Vue.JS. It is a great modern javascript framework inspired by AngularJS and not owned by a big major.

The only drawback I got with it was its little community, and it is something I’d like to avoid from now on.

The alternative at that time (yeah it was few months ago ;)) were AngularJS and ReactJS. Angular was not chosen because version 2 was close to be out but not yet usable. So you understand now why I chose ReactJS? Well not exactly… I tested Angular2 even if it was not ready to be used at that time. I identified that their API + Typescript usage makes backend/frontend writing at the same time smoother than usual.

As this coding was done during my spare time, while I didn’t have major constraints, I decided to wait a bit for Angular2 to choose it as a final solution.

So my fullstack blog is: JPA/JAX-RS/Angular2.

We are done right? Well… not really ! Angular2 promotes typescript usage instead of directly relying on javascript to simplify your code. However, this encourages you to split your application in even more files than a standard javascript one. Thereby, the application would make lots of requests to load. Since we don’t have HTTP/2 yet to make it soft, I needed a way to avoid this side effect. In other words : to avoid loading the application in 30 seconds. So I need a build tool able to transpile typescripts sources and then concatenate and uglify javascript sources.

You can make researches : all java solutions have drawbacks/limitation and *by nature* all good solutions are based on NodeJS. They are the first users so that’s natural 😉

Concerning java, maven was a natural solution, especially because of the quality of tomee-embedded maven plugin which makes the development very easy. More, there is a nice NodeJS maven plugin, so I just needed a NodeJS build solution. Gulp ( was evaluated but was too task-oriented (do it yourself) for a simple project like a blog. Thus, I decided to work with webpack ( which has an insanely easy angular2 starting sample and a very easy built-in API.

Was it the right choice?

In terms of code, I’m quite happy about that stack : I can use TomEE goodness for backend writing and testing (more to come in future posts ;)) Furthermore, Angular2 is simple even for a Java developer. On the build side, the only trick was to ensure to be able to test Java part without building the full frontend task, and the opposite as well. But it is actually easy. Finally, development workflow is quite efficient.

However “all is not rosy”! Angular2 uses RxJs which is insanely great in terms of API and even patterns. However, it makes the frontend quite bigger than the original VueJS solution for instance. They are working on it, and it will likely be improved in the future. It is

not a real blocker, but can have an impact on mobile devices when network is not good enough.

To sum up, I am quite happy with that stack even if some optimizations can still be done and hope this new blog will enable sharing more content in a better manner.

To follow next content you can follow me on or check .

Stay tuned!


JMH and CDI made easy

JMH is a great tool to write microbenchmarks but when you need to integrate it with CDI it can be a bit tricky or you need to break the “common” concept of shade JMH really loves.

However OpenEJB ApplicationComposer provides a built-in solution to this issue pretty neat.

Continue reading

Arquillian, TomEE and big applications: avoid N times the same dump

TomEE arquillian adapters try to make test as isolated as possible but it means if you test a single application in N tests you’ll dump the application N times. For small apps no issue but for big ones it takes time.

To solve it several solutions exist.

Continue reading

TomEE resource properties provider: one more step

I spoke recently ( ) of the ability to read using a custom API properties for TomEE resources but for enterprise context where you want to control all resources it was surely not enough for big applications.

To make it smoother to use you can now:

Continue reading

TomEE and log4j2

Since few weeks TomEE has some support for log4j2 without using log4j2-log4j compatibility module.

To set it up just add the log4j2 jars you want to tomee (lib/) and add your config – log4j2.xml – in the classloader (lib/ works too).

Side note: you can do it using a conf/jars.txt file and using log4j2 maven coordinates, really more easy ;).

Then in conf/ (or in CATALINA_OPTS) set the system property openejb.log.factory to log4j2:


Then you’ll get the container logs redirected to log4j2.

Generic GUI embeddable in a jar?

Writing a GUI for a library/tool is quite common and each time the question how do I do or package it leads to a headache.

You can use any existing web framework but you risk a conflict with the application. So basically the solution is to use client side technology or a jsp/servlet.

Continue reading

Hessian and TomEE/OpenEJB: make remote services insanely fast!

Hessian is an old but very interesting binary protocol known for a very good compromise between compression time and size. That’s probably one of the faster usable for remote webservices.

The question in a JavaEE server is how to use it as transparently as possible? Here is the answer for OpenEJB/TomEE.

Continue reading