Thursday, September 24, 2009

Enabling debugging on Apache tomcat server

Often it is difficult to debug an application deployed on server. So SOP are added in methods.
However this is possible with Apache Tomcat. Add following line to catalina.bat and startup.bat files,

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=8000

After setting these properties, restart the tomcat server.

Go to Run -> Debug Configuration and choose Remote Java Application.
Set up a new configuration with host as localhost and port as JPDA_ADDRESSc i.e 8000.
Click Debug.

This will start a Remote VM debug session which runs in background. Then run your program and the control will enter the breakpoint set by you.

Happy Debugging..!!

Tuesday, September 22, 2009

Spring: java.lang.NoSuchField error : ruleMemo

The error is caused by org.antlr.runtime.BaseRecognizer class. The original antlr distribution, which comes along with standard Apache Ant distribution does not contain a field called ruleMemo in BaseRecognizer class. So if you have original antlr jar used in your application you are likely to encounter this error.
To resolve the error get the latest com.springsource.org.antlr jar from spring framework website. Spring has included the missing field in BaseRecognizer class. Include this jar in your applications lib directory and you are all set to run your spring application

Sending SQL query output to a txt file

To send output of a sql query to a text file use following commands,

spool c:emp.txt
/
select * from emp
/
spool off;

This will write all rows returned by query to emp.txt