JPA and CMT -- Why Catching Persistence Exception is Not Enough?

Being in EJB and JPA world using CMT (Container Managed Transactions) is very comfortable. Just define few annotations to demarcate transaction boundary (or use the defaults) and that’s it – no fiddling with manual begin, commit or rollback operations. One way to rollback your transaction is to throw non-application exception (or application exception with rollback = true) from your EJB’s business method. It seems simple: if during some operation there is a possibility that an exception will be thrown and you don’t want to rollback your tx than you should just catch this exception and you’re fine....

March 10, 2013 · 5 min

Inject Java Properties in Java EE Using CDI

The aim of this post is to show you how, using CDI, you can inject Java properties entries (those in *.properties files) directly into your Java class. This is somewhat similar to the Spring’s @Value annotation I needed in my plain Java EE project. The whole code can be found on GitHub so feel free to clone it, use it or make any changes you like. Context Ok, so basically in a Java EE environment we already have a way to define some properties that are deployment-specific – it’s the <env-entry> element in the descriptor....

June 17, 2012 · 12 min

BTrace -- a Simple Way to Instrument Running Java Applications

Sometimes you need to audit or profile your Java application. The easiest but most intrusive way to do this is to do a bunch of System.out.printlns (which is obviously bad) or to use loggers. After adding a lot of logging statements, your application becomes cluttered with unnecessary boilerplate code. Profiling, instrumentation or method measuring are great examples of cross-cutting concerns that might be nicely solved using AOP (Aspect Oriented Programming.) Basically, it allows you to invoke a certain action upon some defined conditions without the need for changing the instrumented code....

May 5, 2012 · 16 min

Another move towards Git

If you’re interested in getting some basic information about Git, surely you already know about the Git Community Book – it’s undoubtedly a source of great knowledge. However, if you prefer the visual presentation and want to listen about the Git, I will highly recommend Scott Chacon’s “Introduction to Git”. It is great, compact and fast-paced talk about the basics of Git. So, either you know nothing about Git or you already know something and just want to summarize your knowledge – I would highly recommend you to spend this 1,5 h on watching this video....

April 24, 2012 · 1 min

Changing git master after cloning

If you’ve cloned a GitHub repository from the original one and not from your forked version and you would like to change it, you can just edit the .git/config file in your project and change the URL of the origin remote: [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = VALUE_WHICH_SHOULD_BE_ADJUSTED Simple, easy, and most importantly – it works.

September 21, 2011 · 1 min