Modded to work on glassfish and primefaces