Most Java and Linux fanboys might rupture a vain for me saying this, but to get any sort of Java web app going is massive pain in butt. To get Asp.Net going, one merely install visual studio and off you go. You don't even need IIS these days. To get a Java web app (dev environment) going you have to install a web server, an application server, a java framework, an IDE, IDE plugins to support the java framework and perhaps additional frameworks / tools which will allow you to work in a "code-behind" fashion. Then you have to decide on a web frameworks and the choices are endless: Spring MVC, Struts, Seam, JSF, Tapestry, Wicket, Hibernate, Stripes, etc. You can Google until you're blue in the face, but every single framework claims to be the best and all have their own following of groupies. To be honest, it is a big geeky mess!
Unfortunately I don't have the luxury of cleaning up this steaming pile of rubbish, so I'll have to get my hands dirty and figure out what the best solution is through trial and error (very scientific).
My client already has Tomcat running, so luckily I don't have to bother about figuring out which application server is the best. A further requirement is that the web framework should be quite lightweight. It seems as if JBoss' Seam framework isn't too much of a brute, so I'll go with that and probably get burned half-way in.
Even though I detest overcomplicated systems, I've grown quite fond of Gentoo. Once you've mastered this beast, it is quite pleasant to work with. (Perhaps I'll have the same feelings towards Java web apps once I've finished here, but for now it's not looking good.) So I'll run through the steps of getting Seam going on Gentoo.
To start off with, we'll need JDK (or JRE). Login as root, emerge sun-jdk (in my case version 1.6.0.07) and logout. After that we need to get Tomcat.
Note: You can try to get Tomcat going through portage, but you'll end up pulling your hair out, because Seam uses the naming-factory-dbcp.jar, which is not included in the build for some bizarre reason.
Now let's set the environmental variables needed:
tar -xf apache-tomcat-6.0.18.tar.gz
and add these lines:
Note: You might want to emerge the tomcat-native package, since it will add the Apache Tomcat Native library. I'm not sure if Seam needs this, but I noticed Tomcat having a bit of a fit when it couldn't find it. The message in the $TOMCAT_HOME/logs/catalina.out was "INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path"
One can also configure an admin user, but this is not necessarily required. Edit the tomcat-users.xml file like this:
One can now start Tomcat:
<user username="root" password="irock" roles="manager">
You should now be able to access Tomcat on http://localhost:8080
Tomcat will display $TOMCAT_HOME/webapps/ROOT/index.html
So we can now follow Seam's Tomcat guide, which I had to modify a bit:
1. Go into the jboss-seam/examples/jpa directory
2. Copy the lib/hsqldb.jar into $TOMCAT_HOME/lib
3. Run ant tomcat6 to build the application
4. Stop Tomcat $TOMCAT_HOME/bin/shutdown.sh
5. Remove previous any exiting deployments: rm -r $TOMCAT_HOME/webapps/jboss-seam-jpa
6. Copy war file: cp dist-tomcat6/jboss-seam-jpa.war $TOMCAT_HOME/webapps
7. Start Tomcat $TOMCAT_HOME/bin/starup.sh
8. Access the app at http://localhost:8080/jboss-seam-jpa
And Bob's you're uncle!