Friday, August 20, 2010

SerialVersionUID Generator for NetBeans

Are creating serialVersionUID values getting you down?

I have been using 's SerialVersionUID Generator For NetBeans tool for a couple of years now. It used to be available for download from the NetBeans update site, but version 1.9.6 for NetBeans 6.9 has not been available. The current version for use with NetBeans 6.9 can be downloaded from here: eu-easyedu-netbeans-svuid-1.9.6.nbm

This fantastic plug-in is great for generating the serialVersionUID values as part of the Serializable interface contract. If you are doing work with Java Persistence API (JPA) you will definitely want this little plug-in to make your life easier.

  1. You will get a hint on the class about the missing serialVersionUID if you implement Serializable.
  2. Right-click on the class and pick from two options:

    • Add default serialVersionUID
    • Add generated serialVersionUID
Enhanced by Zemanta

Why Movable Type, Drupal, or Wordpress on GlassFish?


The question of relevance has come up on why would you implement Movable Type, Drupal, or Wordpress on GlassFish. Is it because you can?

The answer is one of technology fundamentals and implementation strategies. I am a Java developer (if you could not figure that out from the blog title). I have access to GlassFish which I use for all of my web based application deployments. I want to be able to simplify my administration requirements by using a unified deployment platform. I also want to be able to combine the extensive libraries and frameworks that are available for Java. I want a simple intuitive administration console to handle most of my day-to-day needs. I want administration, and deployment to be scriptable. GlassFish solves a number of these issues, along with using Java, and Java based implementations of some popular languages like JRuby, and Jython.

First, GlassFish versions 2 and 3 are the reference implementations for Java Enterprise Editions (EE) 5 and 6 respectively. If you are doing enterprise software development, and want to use the latest reference versions, you should use GlassFish. I often write about Java Enterprise Edition (EE). I try to focus on the core technology since this keeps it compatible across other EE containers should you choose to move it to another container. GlassFish version 3 has made a number of positive steps in JEE 6 to make it easier to use. The new profiles in GlassFish make it easier to do web development.

Apache web server is very powerful. There is no question about that, but installing modules, and configuring it is not simple. If a module is not available in one of the pre-configured and installed versions on your system, you must compile it yourself. I am a very competent Apache administrator, and I have never had a simple download, and compile deployment. Let me contrast that with GlassFish, if you have Java 6 installed on your system, download and run it. If you are using JRuby, or Jython, GlassFish can handle it right out  of the box. In the case of JRuby, there have been a number of performance tests to show JRuby on Glassfish is faster that Ruby on WEBrick, or Mongrel. The Common Gateway Interface (CGI) servlet will allow you to take advantage of additional CGI technologies with simple configuration on a server wide basis, or on a per application basis.

Apache Web Server and GlassFish can take advantage of a number of frameworks. Apache Web Server can run Ruby applications with the appropriate module. However, it can not take advantage of other independent frameworks. Java on GlassFish allows Ruby developers to use Java frameworks like Swing within their applications. You can even create polyglot applications which use JRuby, Jython, and Clojure. This may be possible  with Apache Web Server, but I am unaware of it. This is a comment point for readers.

Simple and Intuitive administrative interface. That describes GlassFish administration console to a tee. I would even include elegant, and beautiful.

GlassFish Administration Console

Glassfish includes a very complete command-line interface. Anything you can do on the GUI based interface, you can do from the command-line. It also includes a number of advanced features which are not available in the adminstrative GUI.

Finally, as I noted above it has multiple configuration points with languages and technologies including Microsoft technologies.

I have found that GlassFish handles all of my Web based needs in a single platform. This combination of technology and integration points makes it easy to install relevant best of breed software like Drupal, Movable Type, or Redmine on the same platform and integrate functionality between them as necessary. It is very nice to have Redmine and Hudson CI running on the same platform. Combine it with Mercurial, and share a common SSO. This is not done easily on Apache Web Server, or any other platform.

I hope this clarifies my position on its relevance with Movable Type, Drupal, Wordpress, etc.

Wednesday, August 18, 2010

Movable Type 5.x on GlassFish 3.x

Image representing Movable Type as depicted in...Image via CrunchBase

As a number of you know I have done articles on connecting Drupal on GlassFish. The same procedure would work for WordPress on GlassFish using Quercus.

This is a change of track; Movable Type is a Common Gateway Interface (CGI) based application on Perl. GlassFish provides a means, in fact, a default for executing cgi-bin applications and specifically by default Perl.

I am a fan of Movable Type. Perhaps it stems from my earlier years as a developer using Perl. The movable type tags are familiar and follow a JSP/JSF tag library paradigm which also makes its use feel more native to me. So I spent the weekend tweaking the process. I will not move this blog to it since so many of you know where it is at, but I am going to move my personal blog on to it.

Software Requirements:

Movable Type 5.02
GlassFish 3.0.1
NetBeans 6.9.1
MySQL 5.x
Perl 5.8.1+ (OS X 10.6 has Perl 5.10)


The first step is to examine the requirements from Movable Type on which Perl modules are required to run the application. There are also a number of additional modules listed for more functionality. You can add these later as you need them, or be proactive and download them in advance. I will not repeat the requirements from the Movable Type site, but here is a link: Perl Modules.


The MySQL portion simply is installing the database software, creating a database, and adding a user. It is very straight forward.
  1. Install MySQL 5.x.
  2. Create movable type database. From a mysql prompt:

    create database movable_type character set utf8;

  3. Create database user.

    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON movable_type.* TO 'movable_type'@'localhost' IDENTIFIED BY 'movable_type';

    Note: Do not do this in production!

Movable Type 5.x

  1. Download Movable Type 5.02
  2. Unzip the files.
  3. Change the name from MT-5.02 to mt
  4. Change permissions on the mt-static/support directory to 777, or 755 if the application server owns the directory.
    chmod 777 mt-static/support
  5. Create a directory called WEB-INF in the mt directory
NetBeans 6.9.1

  1. Download and Install NetBeans 6.9.1.
  2. Create a new Web Project from Existing Sources.

  3. Name the project mt-project to keep it separated from project code.

  4. Select the directory where the source (.cgi files) are located.
  5. Select the WEB-INF directory you created previously. Alternatively you can download my pre-configured files including the web.xml files here.

  6. The project should be complete and look like the following.

  7. Create a web.xml file which will contain the servlet information needed to run the CGI based applications. Alternatively you can download my pre-configured files including the web.xml files here. The file should contain the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    <description>This is a dummy web.xml file that configures GlassFish 3.x to handle Common Gateway Interface (CGI) applications. Specifically, it is configured for Movable Type 5.x.
    If you need to set additional parameters, please see the default-web.xml file located in the domainX/config directory.
    <display-name>Movable Type 5.x Web Project</display-name>
    <description>Default GlassFish Common Gateway Interface (CGI) Servlet</description>
    <description>0 = Off 1 = On
    <description>A required parameter. It defaults to perl.</description>
    <description>You may change this to point where the *.cgi
    files are located. This sets the path to the main
    project directory. The default is WEB-INF/cgi
    <!-- This is set to point to the default Movable Type application -->
  8. This completes the project.
    Note: You will not be creating a .war file for the application since this will remove the permissions, and executable flags from the *.cgi scripts.
  9. Close the application and move it to a directory location of your choosing for example /usr/local/mt.
GlassFish 3.x

  1. Download and Install GlassFish 3.0.1
  2. Start the application server and verify that it is running correctly.
  3. Deploy the Movable Type application

    asadmin deploy /usr/local/mt

  4. Examine the application from the GlassFish administration. You should see it deployed as an application.

  5. Launch the Configuration Wizard. http://localhost:8080/mt/cgi-bin/mt-wizard.cgi

  6. Set the location of the mt-static static web path. I changed mine to http://localhost:8080/mt/mt-static/
  7. Ensure that the mt-static absolute path is correct.
  8. The next step checks to make sure all of the required Perl modules are installed. If it shows any requirements missing, install them before continuing. This is a clean example.

  9. Configure the database. In this case everything is called movable_type.
    Note: Do not do this in production.

  10. Test the connection. If the connection is successful, you should see the screen below.

  11. Next configure Email. The example below is a representative sample where I chose Sendmail.

  12. Test email.

  13. Congrats! You have configured Movable Type!

  14. Configure your account (Administrative Account).

  15. The next set of steps can be customized depending on how you want to deploy web sites, and blogs to your GlassFish instance. This example will install the files in the document root on the server to make it the default site and blog. Configure your site. Please note in the image below, I have set the root to http://localhost:8080 and the file location to the ../domains/domain1/docroot folder

  16. Click Finish Install

  17. Click on your website and add any parameters you need to set, and click on publish.
    Note: If you don't publish, the site will not be available.

  18. Check out your new Movable Type site!

I hope you enjoyed this tutorial, and will take advantage of Movable Type for creating a web site and blogging.

A great article which describes a lot of detail around CGI on GlassFish v2 and v3 was done by Shing Wai Chan called Common Gateway Interface in GlassFish. His blog explains the Common Gateway Interface (CGI) Servlet in GlassFish, and without it none of this is possible.

Enhanced by Zemanta

Tuesday, August 17, 2010

Floating Point Literal Conversion

IBM 402 Accounting Machine plug-board wiring. ...Image via Wikipedia
IBM 402 Accounting Machine
I read an un-cited article in Doctor Dobb's Journal (DDJ) called A Simple Matter of Conversion. I think that the article was well written about the problem of literal conversion of decimal (floating point) numbers. I will not bother to repeat the article suffice to say that it is interesting from a mathematical, and computer programming perspective.

The article mentions the work of William D. Clinger on floating point conversion. His article is called How to Read Floating Point Numbers Accurately which is linked here.

The article also mentions the work of Guy L. Steele and Jon L. White entitled How to Print Floating-Point Numbers Accurately. This includes a great deal of technical mathematics, but is very well written.

The article also refers to algorithms written by David M. Gay which are implementations of how to produce accurate results. His C based code is located in a source file called dtoa.c. This code is public domain for your use provided you attribute the code as noted in the comments.

I thought I would give it a try in Java on my Mac and see what the results would be without any conversion in the spirit of Mr. Gay's algorithm.

I was surprised that I did not get strange results. My numeric values printed exactly what it should have. I would need to check the code on Java 1.5 to see if there is a difference. I thought it produced a different answer. Perhaps someone else will give it a try and let me know.

 *  Copyright 2010 Blue Lotus Software, LLC.
 *  Copyright 2010 John Yeary <>.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 * $Id: 276 2010-08-18 16:53:46Z jyeary $
package com.bluelotussoftware.example.fp;

 * @author John Yeary <>
 * @version 1.0
public class Main {

 * @param args the command line arguments
public static void main(String[] args) {
float f = 0.1f;
System.out.println("f: " + f);
String fp = Float.toString(f);
System.out.println("fp: " + fp);
float fpx = Float.valueOf(fp);
System.out.println("fpx: " + fpx);

float f1 = (float) (1f / 53f);
System.out.println("f1: " + f1);
System.out.println("f1: " + Float.valueOf(Float.toString(f1)));

String f1x = ("f1x:" + f1);
float f1f = Float.parseFloat(f1x.split(":")[1]);
System.out.println("f1f: " + f1f);

float f2 = (float) 19f / 27f;
System.out.println("f2: " + f2);
float f3 = (float) 8f / 27f;
System.out.println("f3: " + f3);

String f2p = Float.toString(f2);
System.out.println("f2p: " + f2p);

System.out.println("f2+f3: " + (f2 + f3));
System.out.println("f2p+f3: " + (Float.valueOf(f2p) + f3));

f: 0.1
fp: 0.1
fpx: 0.1
f1: 0.018867925
f1: 0.018867925
f1f: 0.018867925
f2: 0.7037037
f3: 0.2962963
f2p: 0.7037037
f2+f3: 1.0
f2p+f3: 1.0
BUILD SUCCESSFUL (total time: 0 seconds)

Here is a link to my NetBeans project:

Enhanced by Zemanta

Wednesday, August 11, 2010

JSONP (JSON with Padding) In Action

Cross-site scripting: a cookie that should be ...Image via Wikipedia
I just read a great article in Dr Dobbs about JSONP In Action. The article discusses the issue of cross-site scripting in browsers, and how sometimes we need to be able to do it. It is simply not just for hackers.

It is interesting that the src attribute in a <script> tag is side can be changed on the e fly. This opens a number of opportunities. The article demonstrates one way using jQuery to update a result based on jQuery.getJSON(url).

I will need to explore this functionality in a little more detail since I have been exploring the possibilities of MongoDB. This would allow a page to be updated from information contained on servers which are not local, and to display data from multiple sources.
Enhanced by Zemanta

Monday, August 02, 2010

What is CollabNet Subversion Edge?

What is CollabNet Subversion Edge? It is beta software. I watched some nice video presentations, and was very excited to try it out. Well it does not offer support in beta on Mac OS X. It does offer support for Windows... figures. I would like to see support for Mac OS X. Linux support is awesome, but there is that other 1/3 of the current computer market that uses Macs.
Subversion project visualization image.Image via Wikipedia

After my complaints about Mac Support, I am not sold on their concept. It looks like a nice convenience, but most of the admins I know are competent enough to set up Subversion, and ViewVC on their own. The other items like LDAP support seem like nice value add items. I am not sure that I want a black box which does updates running Apache in my domain. I like to know how it is configured, and that the security is set correctly. I don't want to have to worry that modifying it will break it. That is just me.
Enhanced by Zemanta

MySQL Sunday | Oracle OpenWorld 2010

Duke, the Java Mascot, in the waving pose. Duk...Image via Wikipedia
MySQL Sunday | Oracle OpenWorld 2010 I wish there was more time at JavaOne. There are so many events going on at the same time that it makes it hard to decide which ones to attend. On Sunday alone, there are two major events: MySQL Sunday, and Java User Groups Sunday. Since I am a speaker at Java User Groups Sunday, and one of the Java User Groups community leaders, I must attend our event. However, l wish I could attend this event too.

Later in the evening, the GlassFish community is going to meet for an unconference and probably a few beverages. The Java User Groups Leaders are having a dinner at the same time across town. Could I clone myself: johnyeary.clone();? I want to attend both. My luck the OpenJDK folks will meet Sunday night too.

This is going to be a different JavaOne. It will be the first since the acquisition of Sun by Oracle. I am curious how it is going to compare to past JavaOne events.

My favorite JavaOne was 2005 with the release of Java SE and EE 5 along with GlassFish. Is this going to be one to remember?
Enhanced by Zemanta

Popular Posts