java

Install RabbitMQ on Debian Squeeze

Install prerequisites and latest Erlang

RabbitMQ can install Erlang for you, but it does not install latest Erlang/OTP, which can cause problems when you try to install Admin UI, so it's the best to just compile latest Erlang/OTP

$ sudo apt-get update
$ sudo apt-get install build-essential
$ sudo apt-get install libssl-dev zlib1g-dev lsb-base 
$ sudo apt-get install ncurses-dev libncurses-dev
$ sudo apt-get install libcurl4-dev libcurl4-openssl-dev 
$ cd /usr/local/src/
$ sudo wget http://www.erlang.org/download/otp_src_R14B03.tar.gz
$ sudo tar xzvf otp_src_R14B03.tar.gz 
$ cd otp_src_R14B03/
$ sudo ./configure 
$ sudo make && sudo make install

Erlang compilation will complain about jinterface, odbc, wx and xsltproc and fop. We do not need any of that for our purposes, so please feel free to ignore.

Install RabbitMQ from Repo

Add the following line to your /etc/apt/sources.list:
deb http://www.rabbitmq.com/debian/ testing main

First Version of LoadTest.IO Released

The very fresh and raw 0.1 version of http://loadtest.io is now available for your enjoyment.

What is It?

LoadTest.io is multi-threaded load-tester with auto-discovery. It is ideal for load-tests that target breadth. You give loadtest.io some initial URLs and it will crawl the rest of your website, auto-discovering links as it goes. It will also try to not repeat already-tested URLs and reach maximum number of unique URLs in the shortest time possible.

Due to this characteristic, LoadTest.io is a very good tool for testing websites that employ caching. Such websites can not adequately be tested by stress-testing tools that only hit limited number of URLs.

Why Would You Care?

The majority of tools currently available do not have auto-discovery feature. Which means they can only test a fixed set of URLs. But any reasonably built web-system has some kind of caching, so after the first hit, any consequent hit to the same URL only tests your cache not - the web system (application layer, database etc). Such test can be unrealistically optimistic and misleading. Real traffic from real users will not just hit 20 hand-picked URLs from your web-site.

Jakarta Commons DBCP Tutorial

A quick code preview showing working example of using one of the best-performing JDBC connection pools in Java.


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;

-- snippet --


        Connection conn = null; PreparedStatement p_stmt = null;

        try {
            conn = ConnectionManager.ds.getConnection();

            p_stmt =  conn.prepareStatement(
            	"INSERT INTO articles (text,url,content) VALUES (?,?,?)");
            p_stmt.setBytes(1, (new String("jsdhgkdjshgkjdshkg")).
            	getBytes("UTF8") );
            p_stmt.setString(2, "http://dsfsfsfdsfdsfda");
            p_stmt.setBytes(3, (new String("aadada")).getBytes("UTF8") );

            p_stmt.executeUpdate();
        }  catch(Exception e) {
                LOG.debug("Failed to execute a JDBC task: ", e );
            } finally {
                try {
                    p_stmt.close();
                    conn.close();
                }  catch ( Exception ex) {
                    LOG.error ( "Failed to finalize JDBC task: ", ex );
                }
            }

-- snippet --

Mobile Computing, The iPhone Way

The confusion is over - Apple revealed the secrets of creating slick iPhone applications.

When Apple announced iPhone in January, this year, the shocking news and the source of much speculation became the alleged lack of third-party application support. An intelligent cellphone without Java/J2ME was so unusual that for a long while it gave Apple-haters a thing to wave in front of everybody's face and left Apple-lovers confused and curious for what it really meant.

The first clarification came during the Steve Jobs's WWDC keynote on June 11th and once again proved how risky it is for mediocre minds to challenge the design decisions of the Cupertino-based centre of innovation excellence. The message was quite short and ambiguous, yet loud and telling: the future of the mobile applications, as Apple saw it, were Web applications.

SOA In Buzz-Word Laden Prose

SOA is probably the most overused/abused buzzword. I would say even more so than AJAX - which is scary, really. It's also funny how "SOA experts" can make the subject even blurrier.

That was the subject of the conversation between Doug and I, recently that I am quoting below. We were discussing a recent SOA article. Nothing too serious, just fun.

irakli: Got a minute?
dharris: sure
irakli: Trying to catch a blasphemy in this: http://www.theserverside.com/tt/articles/article.tss?l=ChurchandState

Breakthrough: Java Implementation of PHP5

According to Caucho, you can run Drupal in Java now.

Following is the excerpt from Quercus website:

"Quercus is Caucho Technology's 100% Java implementation of PHP 5 released under the Open Source GPL license. Quercus comes with many PHP modules and extensions like PDF, PDO, MySQL, and JSON. Quercus allows for tight integration of Java services with PHP scripts, so using PHP with JMS or Grails is a quick and painless endeavor.

With Quercus, PHP applications automatically take advantage of Java application server features just as connection pooling and clustered sessions.

Quercus implements PHP 5 and a growing list of PHP extensions including APC, iconv, GD, gettext, JSON, MySQL, Oracle, PDF, and Postgres. Many popular PHP application will run as well as, if not better, than the standard PHP interpreter straight out of the box. The growing list of PHP software certified running on Quercus includes DokuWiki, Drupal, Gallery2, Joomla, Mambo, Mantis, MediaWiki, Phorum, phpBB, phpMyAdmin, PHP-Nuke, Wordpress and XOOPS."

This is very impressive. I am going to try installing Drupal over Quercus soon and share the experience.

Incorrect Date Formatting in Sun JDK 1.5 Russian Locale Implementation

Even though Russian is one of the few languages i can speak and I have worked on both the internationalization of Web applications, as well as Java quite a lot, in the past, particular problem of Russian i18N has never come to my attention. That is - until now.

Unfortunately, I was unpleasantly surprised as soon as I touched it - Sun JDK 1.5.x does not format dates correctly with Russian Locale.

The deal with Russian language is that month names have different suffix when they are presented stand-alone (i.e. in a list or smth) and yet another one when they are part of a formatted date. So, even though March is "Март" in Russian, correctly formatted today's date would be: "7 Марта 2007 г."

Let's see how JDK fortmats today's date: 7 Март 2007 г. Clearly wrong.

It's very sad. No matter how you feel about it, Russian is one of the major languages and Sun could have put enough effort to get it right.

Below is the test JSP code:

<%@page pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>

<HTML>
<head>
  

Marc Fleury Quits JBoss

The biggest news of the day, in the tech industry, is that Marc Fleury has quit JBoss/RedHat. Honestly, I do not think there is much to say about this fact. As soon as RedHat acquired JBoss many of us knew it would happen, because of how unfitting Fleury's personality is in a culture like RedHat.

I will just say that I hope Marc will prove himself for the entrepreneurial visionary he has been marketing himself as and will start something new with the money he collected. I would presume "new" would be something in more agile arena: Ruby On Rails, Drupal, Ajax are first things that come to mind.

I really hope he does. It would be interesting.

Exception Handling and the Chain of Responsibility Design Pattern

Developers often compain about explicit Exceptions, especially in a strongly typed language like Java, and how much real estate handling those takes up in source code.

I have seen approaches when people try to avoid java.lang.Exception and fall back to java.lang.RuntimeException for most cases. Is that a good thing to do? RuntimeException is a valid choice for certain cases but overusing it beats the whole idea of exception-handling, really.

As part of my responsibilites as a software architect, I get to review code of many developers. I think the problem, in most cases, is incorrect usage of exception-handling. More specificly, developers overdo with catching exceptions at the lowest level - at the same spot they expect exception to be fired. Passing it up the class hierarchy is often needed but not done. It is especially true in the case of more junior developers (however, you quickly find out that many "senior" developers are vulnarable, as well).

BEA Weblogic on OS X

Following are detailed instructions for installing Weblogic 9.1 on OS X Panther.

Download AIX version of Weblogic 9.1 (AIX as that's the generic version of WebLogic, in fact). You can download it from:http://commerce.bea.com/showproduct.jsp?family=WLS&major;=9.1&minor;=0

Run the installation with the following command:
java -Dos.name=unix -jar server910_generic.jar

it's crucial to indicate os.name parameter. Otherwise, installer will complain about insufficient disk space.

At the end of installation you will be asked whether to run QuickStart. I recommend not to, as it hung on me.

In any case, you need to create a new weblogic domain, first by running:
~/bea/weblogic91/common/bin/config.sh

Domain creator will ask about JDK. It actually manages to find Apple's one but in case that fails, indicate the following path:
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home

To run the server, go to the following directory from Terminal:
~/bea/user_projects/domains/<domain_name>
e.g. if your domain name is "base_domain" then go to:
~/bea/user_projects/domains/base_domain

and then run:

Syndicate content