Sunday, 29 July 2012

Upgrade Hibernate from 3.1.3 to 3.6.10.Final using Maven

At the time of writing Hibernate is well into its 4.X releases with 5.X in sight so if you are looking to migrate from 3.x to 4.x read this or If you need a specific migration guide look here.

In my case I needed to migrate our application from 3.1.3 to 3.6.10.for which I have detailed the steps below.


  • Make sure that you have the necessary repositories to download the required Jars. You might need.


       mvn-public
       MVNRepository
       http://mvnrepository.com


       repository.jboss.org-public
       JBoss.org Maven repository
       https://repository.jboss.org/nexus/content/groups/public
  


  • Add the following dependencies into your pom.xml
   
  
   org.hibernate
   hibernate-core
   3.6.10.Final
  
  
  
   javassist
   javassist
   3.12.1.GA
  

Since Hibernate 3.4.X onwards, Hibernate switched to SL4J, you'll need:


   org.slf4j
   slf4j-log4j12
   1.5.6
  
  
   log4j
   log4j
   1.2.16
  

Now, configure your connection poolDownload the c3p0-0.9.1.2.jar from here and load it into your Tomcat/lib along with your MySQL driver jar.


Add the following configuration settings in your Hibernate (.properties or .cfg.) file.

5
20
300
50
3000

That's it !!
You WAR/lib should have the following jars present post-migration.
  • commons-collections-3.1.jar
  • hibernate-commons-annotations-3.2.0.Final.jar
  • hibernate-core-3.6.10.Final.jar
  • hibernate-jpa-2.0-api-1.0.1.Final.jar

  • javassist-3.12.1.GA.jar
  • jta-1.1.jar
  • slf4j-api-1.5.6.jar
  • slf4j-log4j12-1.5.6.jar


Tuesday, 24 July 2012

Monitor your Tomcat Server with Psi-Probe

Psi-Probe is an excellent Tomcat and JBOSS server monitoring tool. Setting it up is as easy as uploading the application, which comes packaged as a WAR file. Before setting it up, create a user with the role probeuser, in your conf/tomcat-users.xml.
Psi-Probe allows you to manage and monitor the server's health (memory usage, cpu usage, OS and server information) as described in the screenshot below.
PSI-Probe Memory Monitoring Console

Psi-Probe also allows you to restart the server JVM and kill threads. Another interesting feature of Psi-Probe is that you can see which jsps are not being used by the application. These jsps get tagged with the status 'outdated' while the jsps which are being used by the application  have a status of 'compiled'. Further, you can also manage requests based on session IDs and monitor the average response time.