Java 1.4 and Stripes

Skip to end of metadata
Go to start of metadata

Stripes uses a lot of Java 5 features in order to make life easier. But that doesn't mean that it can't run on a Java 1.4 JVM. It just takes a little more work. This document walks through the process of using Retrotranslator to make a Stripes application work on in a Java 1.4 environment, using the Stripes examples web application as, well, the example.

Building Stripes from Source

At the time of writing there is one Java 5 feature that Stripes uses that is not supported by Retrotranslator. This has been fixed in the Stripes subversion source tree, and will be released as part of Stripes 1.3.2. Until such time, it is necessary to build Stripes from source in order to work with Java 1.4. The following shows how to get a working build of Stripes from source. You'll need to have ant and a subversion client installed.

~ 1 # mkdir /sandbox
~ 2 # cd /sandbox
/sandbox # svn co -r 310 https://stripes.svn.sourceforge.net/svnroot/stripes/trunk .
/sandbox # ant dist

Downloading and Installing Retrotranslator

Next, go and grab Retrotranslator from Sourceforge. Unpack it and you should see something like the following:

ASM-LICENSE.txt
LICENSE.txt
backport-util-concurrent.jar
changelog.txt
readme.html
retrotranslator-runtime-1.0.4.jar
retrotranslator-transformer-1.0.4.jar

The first two jars contain classes that must be present at runtime, so they need to get copied into the application's classpath. In the case of the examples application, we'll copy them into the WEB-INF/lib directory:

~ 3 # cp Retrotranslator-1.0.4-bin/retrotranslator-runtime-1.0.4.jar /sandbox/examples/web/WEB-INF/lib
~ 4 # cp Retrotranslator-1.0.4-bin/backport-util-concurrent.jar /sandbox/examples/web/WEB-INF/lib

Go Retro

We need to Retrotranslate both stripes.jar and any classes in the examples application that use Java 5 constructs. To do this we'll execute Retrotranslator from the command line as follows:

/sandbox/examples/web/WEB-INF 5 # java -cp lib/retrotranslator-runtime-1.0.4.jar:lib/backport-util-concurrent.jar \
 ~/Retrotranslator-1.0.4-bin/retrotranslator-transformer-1.0.4.jar -srcjar lib/stripes.jar

/sandbox/examples/web/WEB-INF 6 # java -cp lib/retrotranslator-runtime-1.0.4.jar:lib/backport-util-concurrent.jar \
 ~/Retrotranslator-1.0.4-bin/retrotranslator-transformer-1.0.4.jar -srcdir classes

We're almost done. We need to make one last change, replacing references to Java 5 classes in the Tag Library Descriptor. You can do this at the command line, or using your favorite editor. E.g.

~ 7 # cd /sandbox/examples/web/WEB-INF/lib

/sandbox/examples/web/WEB-INF/lib 8 # jar xvf stripes.jar /META-INF/stripes.tld /META-INF/stripes-dynattr.tld

/sandbox/examples/web/WEB-INF/lib 9 # sed s/java.lang.Enum/net.sf.retrotranslator.runtime.java.lang.Enum_/ \
 stripes.tld > tmp && mv tmp stripes.tld

/sandbox/examples/web/WEB-INF/lib 10 # sed s/java.lang.Enum/net.sf.retrotranslator.runtime.java.lang.Enum_/ \
 stripes-dynattr.tld > tmp && mv tmp stripes-dynattr.tld

/sandbox/examples/web/WEB-INF/lib 11 # jar uvf stripes.jar META-INF/

/sandbox/examples/web/WEB-INF/lib 12 # rm -r META-INF/

And we're done! You should now be able to jar up the contents of the web directory and deploy it to a server running under Java 1.4 and it'll work!

Ongoing Development

While it's only necessary to Retrotranslate stripes.jar once, it will be necessary to integrate a step into the build process of your application to Retrotranslate your application code after each compilation. You could do this through the command line in a manner similar to the one described above, but that seems a bit manual. Luckily Retrotranlator provides an ant task as part of the distribution, and there is also a maven plugin available. Instructions on using both are available from the Retrotranslator Homepage.

Known Issues

The only known issue at this time concerns the BigDecimalTypeConverter and the BigIntegerTypeConverter. At present these use an API that was added in Java 5 and is not currently supported by Retrotranslator. As such, if you need to use BigDecimal and BigInteger values in forms, you will need to create your own implementations of these classes.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.