JRebel constantly reloading every class file and every configuration file in our Java project

Submitted by Jochus on Mon, 19/11/2012 - 23:04 | Posted in: Java
Posted in

We are using JRebel at work now for a couple of weeks, and this product is really a timesaver for every Java developer. No need to redeploy/restart your application server: just code and push refresh in the browser.

But, we sometimes had the issue the whole project was getting reloaded and we only changed 1 line of code in 1 class file. After a bit of research, we found out Eclipse just cleans the whole bin folder. Every class file was recompiled.

The reason why is still unknown. I couldn't figure this out. Anyways, it was really frustrating as the only solution to stop the reloading process, was to restart the application server. And if you have to restart the application server, why would you use JRebel?

The first thing I tried is stopping the "Automatic build" option in Eclipse. Disabling build automatically option does not break JRebel. JRebel depends on the results of the compilation, so if you disable the automatic build you will have to just compile the changed classes yourself, that's it.

But I didn't like that option either, so we found an option in JRebel which is actually a VM argument: -Drebel.check_class_hash=true which will check the checksum before reloading the classes. It may slow down the reloading time from a few milliseconds to some milliseconds extra. But it is still better than the situation when all the project classes have to be reloaded.

To summarize, this is my JRebel configuration in $JBOSS_HOME/bin/run.conf:

# JRebel
JAVA_OPTS="$JAVA_OPTS -javaagent:$JREBEL_HOME/jrebel.jar -Drebel.log=false -Drebel.check_class_hash=true"
JAVA_OPTS="$JAVA_OPTS -D##PRODUCT_NAME##.root=/Users/jochen/Documents/workspace/##PRODUCT_NAME##"

CSS3 spin animation

Submitted by Jochus on Tue, 13/11/2012 - 16:56 | Posted in: Website
Posted in

I just learned this cool CSS3 animation on Devoxx :-)! Hover the Chrome logo!
Not sure it's gonna work on Internet Explorer ... :p ...



Logging all queries executed on MySQL database

Submitted by Jochus on Mon, 12/11/2012 - 23:23 | Posted in: Database
Posted in

I wanted to debug some SQL queries which are coming from my data access layer (JPA with Hibernate) and which are being send to my MySQL server. The following steps are needed:

  • Create the file /etc/my.cnf (I installed MySQL manually from a .pkg installer, so the file is not there by default - you have to create it manually)
  • Add the following lines:

  • Create the .log file:
    $ sudo touch /tmp/mysql-query.log
  • Allow MySQL daemon to write in file:
    $ sudo chown _mysql /tmp/mysql-query.log
  • Restart MySQL daemon:
    ~ $ cd /usr/local/mysql/support-files/
    /usr/local/mysql/support-files $ sudo ./mysql.server restart

Cleaning the cache of address book in Outlook for Mac 2011 (Global Address List on Microsoft Exchange)

Submitted by Jochus on Sun, 11/11/2012 - 22:43 | Posted in: Mac
Posted in

When connecting from Outlook for Mac 2011 to a Microsoft Exchange server, Outlook caches the Global Address List for a day. Changes made on the Exchange server, are not directly visible in your Outlook.

If you want to force an update, you can follow the steps below:

# Close Outlook
~ $ cd Library/Caches/Outlook/Main\ Identity/1/
~/Library/Caches/Outlook/Main Identity/1 $ rm OABQueryInfo.plist 
# Startup Outlook - the latest version of the address book will be retrieved from the server

Rolling back a transaction in TransactionManagementType.CONTAINER EJB

Submitted by Jochus on Tue, 06/11/2012 - 22:33 | Posted in: Java
Posted in

Rolling back a transaction in a TransactionManagementType.BEAN

First of all, there's a difference with a TransactionManagementType.BEAN EJB. When an EJB is marked with the @TransactionManagement(TransactionManagementType.BEAN) annotation, transaction management is performed by calling the methods in the UserTransaction class.


public class FooBarBean implements FooBar {
	private UserTransaction tx;
	public void someMethod() throws Exception {
		try {
			  // do something 
		} catch(Exception ex) {
                          throws ex;

For every method in which you need a transaction, you have to control the UserTransaction by yourself.

Rolling back a transaction in a TransactionManagementType.CONTAINER


public class FooBarBean implements FooBar {
	private EJBContext context;
	public void someMethod() throws Exception {
		try {
			// do something
		} catch(Exception ex) {
                        throws ex;

The transaction will be automatically started at the start of the method and it will be committed at the end of the method.
The moment when context.setRollbackOnly() is invoked, the transaction will just be marked as rollback only and nothing will be persisted when the method ends and returns.

Upgrading Python to version 2.6 on Ubuntu Intrepid 8.10

Submitted by Jochus on Thu, 25/10/2012 - 21:37 | Posted in: Linux
Posted in

I have an old Ubuntu 8.10 server running at home. Today, I wanted to create a script which needs Python. The latest version of Python in the Intrepid Ubuntu repository is 2.5, but I needed 2.6. Luckily, it's very easy to install 2.6 from source and run it next to the 2.6 version!

  • Download the Python 2.6 sources from http://www.python.org/download/releases/2.6.8/
  • Unzip and execute the following commands
    $ sudo ./configure --prefix=/usr/lib/python/2.6
    $ sudo make
    $ sudo make install
  • You are now able to use Python 2.6 from: /usr/lib/python/2.6/bin/python

Retrieving the number of physical/logical CPU's in Windows + detecting HyperThreading support

Submitted by Jochus on Tue, 23/10/2012 - 22:56 | Posted in: Windows
Posted in

If you want to get the number of physical CPU cores, execute the following command:

for /F "tokens=2 delims==" %C in ('wmic cpu get NumberOfCores /value ^| findstr NumberOfCores') do @echo %C

If you want to get the number of logical CPU processors, execute the following command:

for /F "tokens=2 delims==" %C in ('wmic cpu get NumberOfLogicalProcessors /value ^| findstr NumberOfLogicalProcessors') do @echo %C

If the ratio of the above 2 numbers is 1/2, it means your CPU supports HyperThreading.

Defining system variables in Mac OS X

Submitted by Jochus on Tue, 23/10/2012 - 17:07 | Posted in: Mac
Posted in

If you want to define a system variable in Mac OS X, and you want all of your applications (commandline, GUI, ...) to be able to pick them up - then you need to follow the steps:

  • Open a terminal
  • Execute the command:
    $ sudo nano /etc/launchd.conf
    Remark: In my case, the file didn't exist, so don't worry if you need to create it
  • Insert the following text (I added 2 examples: JAVA_HOME and JREBEL_HOME)
    # Set environment variables here so they are available globally to all apps
    # (and Terminal)
    # After editing this file run the following command from the terminal to update 
    # environment variables globally without needing to reboot.
    # NOTE: You will still need to restart the relevant application (including 
    # Terminal) to pick up the changes!
    # grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
    setenv JAVA_HOME /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    setenv JREBEL_HOME /Applications/eclipse/plugins/org.zeroturnaround.eclipse.embedder_5.0.1.RELEASE-201207191833/jrebel