Sunday, 29 January 2006

The Journey Begins

I picked up Head First Servlets & JSP. Great book! I love the irreverant writing and the learning philosophy, meta-cognition.

Lots of questions. A mock exam. Puzzles. Sidebars. Thinking games. Satire. Pro UNIX/BSD. Tomcat.

Chapter 1 is a solid review of HTTP and HTML. There is a good introduction to Tomcat deployment actually in this first chapter, just to satisfy the impatient. Nothing I’m not already familiar with actually, but a good review of the foundations of what makes it all work while introducting Objective 1.1 of the SCWCD exam.

The authors love one thing: beer. And maybe one other, I’ll let you work out this puzzle: what’s with all the 4:20 references, there’s even a 24 hour clock 4:20 reference (16:20:01)! Too many happy coders on the slopes out there in CO? I think! :)

Posted by caffeinated at 10:19 PM in SCWCD

blojsom, anti-splog, and captcha

Yesterday was a banner caffeinated day: blojsom captcha plugin, SCode by Cliffano Subagio, was implemented after some configuration headaches.

blojsom documentation has been updated since by myself and Cliffano. For posterity, I wanted to note some of the finer details of the origin of the problems and how they were solved.

The SCode Plugin

Cliffano's SCode Plugin is a nice little servlet that uses the open source jCaptcha library to create images with numeric codes that must be entered before posting comments. The gist of this effort is to reduce or eliminate comment spam in one's blog.

The blojsom documentation was thorough and easy to follow, but it contained a trival configuration slip and made an assumption about the host running the blojsom webapp. The configuration error was simple to address (and has been corrected in the online documentation); the host assumption was a bit more difficult to address, if only because it was an assumption and because the configurator, me in this case, looked right at the solution and failed to see it in the error being presented.

Configuration

The trivial configuration slip noted above, and still the source of some questions, was an <init-param> block for the SCode servlet definition in the webapps web.xml. For this instance of blojsom, running on Tomcat 5.0.28, defining the <init-param> for the scode.properties in the servlet definition failed. The servlet loaded, but the parameter could not be seen by the blojsom servlet.

Still being debated is the why—some servlet containers apparently scope the init-params globally—but the solution was to move the SCode's <init-param> block out of the SCode definition and into the blojsom servlet definition where other similar property files were loaded. A more knowledgeable reader might be able to explain how this works in various versions of Tomcat and other servlet containers.

Hosting assumptions

YMMV with the following, as such, yet more assumptions will be made: you’re running blojsom on a Virtual Dedicated or Private Server (VPS) and your OS is some commercial or open-source variant of BSD—this includes Mac OS X (“Ten”, not “Ex” )—or GNU/Linux. This writer cannot vouch for behaviors in Microsoft/IIS hosting environments.

Most VPS hosts run “headless”, meaning that you do not have a physical monitor attached to the server. You may be remotely administering the server via SSH, a VPN or Serial console over SSH, or... well, you get the idea. Headless does not mean that the host did not consider virtual monitors through X consoles and the like, but your host might be cautious or be considering other factors such as memory or storage limits, thus not install the necessary X libraries to run X servers for virtual terminals.

This does not mean that you as the VPS administrator cannot install the libraries for X, it just means that you have to weigh the impact to your hosted environment if you do so. Do you need an X console? Probably not, but Java likely will need the X libraries to run a headless environment. Java does this with the system property java.awt.headless=true. In fact the SCode configuration notes this property as something to consider.

Now, all this has been said before and more succiently by Philip Isenhour at JavaTechniques. Philip's Linux X11 Libraries for Headless Mode page has the background and detail you need.

It is enough to say that my VPS host did not install the X libraries and I ended up with UnsatisfiedLinkErrors. Some research on Google (finding Philip's resource) and some knowledge of Linux distros, solved my problem. For the Fedora Core series I determined the following packages provided the necessary X libraries to satify the link errors on my Java/blojsom/OS combination (again I need to say, YMMV):

  • Fedora Core 2:  xorg-x11-libs
  • Fedora Core 3+: xorg-x11-deprecated-libs

Philip's notes are more focused and tell you exactly what libraries are needed in a Java 1.4 environment, whereas the above packages have dependcies that need to be satisified. If the dependencies are a non-issue, load them, otherwise consider a method to get just what you need; Philip outlines how one might go about doing so on RHL9.

Fill the bit-buckets

With the blojsom notes, Philip's resource, and my tribulations, I hope to fill infinite bit-buckets with comment spam. May your days too be comment spam free.

Posted by caffeinated at 9:51 AM in kaffehaus
« January »
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031