Accessing local variables even after methods finish (in Java)

Submitted by Kamal Wickramanayake on December 3, 2010 - 01:42

At times we write methods in Java classes with local variables that we need to access even after the methods finish execution. Here's an example:


public class FinalLocalVariableTest {

    public static void main(String[] args) {
        final int x = 5;

        Runnable r = new Runnable() {            
            public void run() {
                System.out.println("x is " + x);

        Thread t = new Thread(r);

Java Programmatic Browser

Submitted by Kamal Wickramanayake on July 19, 2010 - 10:54

At times you need to visit web sites, login, navigate through pages, select portions of HTML, click on links, check for the existence of a form, submit the form,.... and do all these things programmatically. So you need a programmable web browser that can execute and have a cup of tea while it will do the job.

Java programmatic browser

Sample X.509 certificate collection with public/private keys (for Java)

Submitted by Kamal Wickramanayake on July 10, 2010 - 09:39

If you want to test your Java application which requires digital certificates, here's a collection of such certificates with associated public/private keys in .jks format (the Java standard format - Java Key Store).

For example, you can use these to test Web services or enable SSL support of a Java server (and clients - if you want).

Using Spring Security in your Java web application

Submitted by Kamal Wickramanayake on July 9, 2010 - 07:50

Spring is a great application framework extensively used in Java applications. Spring Security is yet another open source product from the same company that provides extensive security features going beyond what is in the Java Enterprise Edition specifications (Servlets, EJB). Interestingly, you can use Spring Security in any application server you like without modifications to your application. So your security configuration is not going to be different in different environments, it  becomes portable too.

JAX-WS Web services in JBoss 5 do not work (JDK 1.6, Eclipse IDE)?

Submitted by Kamal Wickramanayake on June 12, 2010 - 07:19

Environment: JDK 1.6, JBoss 5.1, Eclipse 3.5 (Galileo)

I came across the following JBoss error when a JAX-WS Web service was accessed:

11:15:18,008 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
    at javax.xml.soap.SOAPMessage.setProperty(

Configuring a JBoss + Spring + JPA (Hibernate) + JTA web application

Submitted by Kamal Wickramanayake on November 6, 2008 - 16:38

Updated version available: If you are looking for how JPA can be used in JBoss 5 and Spring 3.x versions, look at "Spring JPA web applications (JTA transactions, JBoss 5)". What you find below is a workaround to use JTA transactions in JBoss 4.x versions.

Here's how one might go about deploying a Spring application in JBoss (4.something) that uses JPA with Hibernate as the provider for persistence and JTA for transaction demarcation.