Thursday, December 6, 2012

How to access Environment Variables in an ANT build script

Often you tend to require to write an ANT build script with references to Environment Variables like 'JBOSS_HOME' or 'JAVA_HOME'.

This can be achieved using the following:
<property environment="env"/>
<property name="JBOSS_HOME" value="${env.JBOSS_HOME}"/>
<property name="JAVA_HOME" value="${env.JAVA_HOME}"/>

Tuesday, December 4, 2012

How to start JBoss in debug mode?

In order to start JBoss in debug mode, all you need to do if edit the run.conf.bat file if you are on a Windows machine and add the following debug option:

set JAVA_OPTS=-Xdebug –Xrunjdwp:transport=dt_socket, address=8787, server=y, suspend=n %JAVA_OPTS%

You may choose another port as against using port 8787 mentioned above if port 8787 is already in use on your machine.

Issues with persisting Date | Hibernate - Annotations

Very recently I came across a situation where in the Date that was being persisted into the database was saving the Date correctly but the Time was being saved as “00:00:00”.

·         Hibernate – Annotated
·         Oracle 11g

The issue was resolved by changing the value of the TemporalType Enum in the @Temporal annotation carried by the getter of the respective attribute in the domain object from TemporalType.DATE to TemporalType.TIMESTAMP.

The annotation @Temporal must be specified for persistent fields of type java.util.Date and java.util.Calendar. It may be used only for fields of these types. This annotation can be used in conjunction with the other basic annotations like Id.