20. May, 2009

Taking the SCJP

Filed under: Java,Software Development — frightanic @ 23:53

This blog now resides at It will be discontinued here…

Reading a book on the Sun Certified Java Programmer (SCJP) test is interesting and worthwhile, but the test itself is bogus.
Says who? I do…

I took the SCJP for Java 2 many many years ago and subsequently also passed the SCJD and SCWCD tests. So, I feel I experienced a fair share of the Sun certification universe.

SCJP is known as the “API test” and its successful completion is the basis for all other Sun Java certificates. You’re expected to be familiar with many of the basic Java/OO concepts and APIs – sometimes down to the method signature. As such, passing the test shouldn’t require at lot of studying for any serious Java engineer since this is our daily bread and butter.
So, going through a certification prep book should hopefully not teach you a lot of new stuff (i.e. things you weren’t previously familiar with) but rather fill your know-how gaps. And that’s the interesting part. You might uncover surprising aspects of the JLS (Java Language Specification) which can be valuable.

However, it’s the way questions and code samples are formulated in the test that hamper the significance of its results. The time limit for the full Java 6 test is 210min (yes, that’s 3.5h!) and it consists of 72 questions. While you may finish a lot quicker it certainly is a primary test for your ability to concentrate in a test center. Furthermore, the majority of the questions contain code samples that are outright silly. You’ll see code that no sensible programmer would ever craft like that – even if the JLS allowed it.
You job would then be to find the missing ‘;’, the missing ‘static’ modifier, the illegal [] in an array declaration, the overridden instead of overloaded method, the illegal auto-boxing, the… you name it i.e. mainly stuff the compiler would report anyway. Finding the correct answer has become harder over the years because for most questions two of the possible answers nowadays are “Doesn’t compile” or “Fails at runtime”.

So, practicing for the test is not so much about learning Java as it is about getting accustomed to this type of questions and finding a (personal) strategy to tackle them.

All in all, I don’t think a Java test which a good Java developer might still flunk has a lot of significance. And passing this test doesn’t necessarily mean that you’re a good developer, either. Pity.


2. May, 2009

There’s no such thing as a “static inner class” in Java

Filed under: Java,Software Development — frightanic @ 16:53

This blog now resides at It will be discontinued here…

It was only recently after many years of Java programming that I found out that there’s no such thing as a “static inner class”. Such classes are called static nested classes.


25. January, 2009

GWT widget libraries, a market overview

Filed under: Java,Software Development,Web Authoring — frightanic @ 15:37

This blog now resides at It will be discontinued here…

After many hours searching the Internet for GWT widget libraries, analyzing them, and taking notes I thought I might as well publish my findings here. Feel free to comment and point out inconsistencies.

At the moment the market seems to be split into two segements:
– a few small or medium-size, low-key libraries with little activity
– the whole “Ext” gang

However things change very quickly, in a matter of months, and the end of 2008 saw the advent of a new-kid-on-the-block: SmartGWT.

Small, or medium-sized libraries

  • GWT-SL/WL, a collection of server- and client-side tools. No real show case that demonstrates the power of the library is available. Last minor release in December 2008. Little SVN activity over the entire course of 2008.
  • GWT Tatami, based on the DOJO JS framework. Show case isn’t impressive, but project is active. Continuous SVN activity. Road map for first half of 2009 available.
  • GWTLib, continuous but little SVN activity. Offers hardly anything else but but table-centric widgets.
  • GWT Tk, tbd
  • Rocket GWT, tbd
  • “vanilla” GWT, Google’s on-board GWT widgets. Nothing fancy, but clean and slick.

The “Ext” corner
A long time ago (think Internet time ;-)) a guy called Jack Slocum built an extension to Yahoo’s YUI widget library named YUI-Ext. It evolved and became independent, Ext JS was born and with it a new company: The library quickly became very popular.
Once GWT was released people started writing widget libraries for it. Boston-based Sanjiv Jivan started GWT-Ext and based in on Ext JS. Darrell Meyer wrote MyGWT, a pure GWT widget library which shared the Ext JS l&f. It was voted #1 widget library one year ago.
In April 2008 things became very nasty an confusing when Jack Slocum changed the Ext JS license from LGPL to GPL thereby forcing GWT-Ext to stick with Ext JS 2.0.2 which was the last version available under LGPL. Furthermore, he hired Darrell Meyer who brought his MyGWT as a dower into the relationship. As a result, Ext JS published its own GWT widget library called Ext GWT. Now developers had the choice between GWT-Ext (full OSS with LGPL) and Ext GWT with a dual-licensing model. The GWT widget “war” (see references 1-5 below) turned many away from Jack Slocum’s Ext JS because they disliked the way the company treated the GWT community.
On November 26th, 2008, the game changed again when the GWT-Ext crew announced that they would no longer build major new features but instead be migrating to SmartGWT, a library created by GWT-Ext developer Sanjiv Jivan . SmartGWT 1.0 had been announced only two weeks earlier.


6. September, 2008

Inserting data into an Oracle LONG field with Spring JDBC

Filed under: Java,Software Development — frightanic @ 17:32

This blog now resides at It will be discontinued here…

I struggled to update the content of a LONG column in an Oracle database with Spring JDBC. However, (in retrospective) this is more of a general JDBC problem than a Spring problem.

The problem first occured when I tried to use a regular SQL update statement to save a few thousand characters in that LONG field.

simpleJdbcTemplate.update("update mytable set content = ? where id = ?", new Object[] { o.toString(), o.getId() });

Hence, I tried to execute the same statement in a SQL editor, Oracle’s SQL Developer in my case, and got “ORA-1704: string literal too long” as a feedback from the database. Further analysis revealed that the LONG datatype has been deprecated in Oracle ever since 9i. It can hold 2GB max. but you’re encouraged to use CLOB instead. Some poking around the JDBC pages at revealed sample code that describes how to manipulate LONG fields:

Now, whether the below code is optimized or not is yet to be seen. It solves my problem, though.

final LobHandler lobHandler = new DefaultLobHandler();
final byte[] contentBytes = o.toString().getBytes();
final InputStreamReader clobReader = new InputStreamReader(new ByteArrayInputStream(contentBytes));
simpleJdbcTemplate.getJdbcOperations().execute("update mytable set content = ? where id = ?", 
    new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
    protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
        lobCreator.setClobAsCharacterStream(ps, 1, clobReader, contentBytes.length);
        ps.setString(2, o.getId());

5. August, 2008

Character encoding error from Eclipse while saving

Filed under: Apple & Mac,Software Development — frightanic @ 17:05

This blog now resides at It will be discontinued here…

What to do when the following error pops up in Eclipse while saving a file:

Save could not be Completed
Some characters cannot be mapped using “<your-encoding-here>” character encoding.
Either change the encoding or remove the characters which are not supported by the “
<your-encoding-here>” character encoding.

If you’re certain that the encoding is correct an you didn’t enter any weired characters, you should copy/paste the content of the file to an external editor and see if it tells you where those hidden, special characters are.

On Linux and Mac you may as well abuse the terminal for that for certain character set. Just paste the code to the shell and see if you find anything unusual.

15. April, 2008

Java SimpleDateFormat and 4-digit year vs. 2-digit year

Filed under: Java,Software Development — frightanic @ 23:35

This blog now resides at It will be discontinued here…

At the end of an already long day a co-worker and I recently came across the problem that

new java.text.SimpleDateFormat("dd.MM.yyyy").parse("03.03.08");

does not return March 3rd, 2008 but March 3rd, 0008 instead.

As any decent engineers would, we headed for the respective API documentation right away to see whether there was an explanation for this behavior. Like any bad engineers, however, we didn’t pay close enough attention to the details in the documentation and tried to fix the problem with the wrong tools. Since our customer forces us to develop for the WebSphere platform, hence for an IBM Java runtime, we even suspected that this might be the cause for our confusion. Shame on us! We were barking up the wrong tree. It’s all there in the JavaDocs if you read it carefully:

“For parsing, if the number of pattern letters is more than 2, the year is interpreted literally, regardless of the number of digits. So using the pattern “MM/dd/yyyy”, “01/11/12″ parses to Jan 11, 12 A.D.”

Ok, that’s the explanation, but what is the solution if you need “03.03.08” or “03.03.2008” to be parsed into March 3rd, 2008? As so very often I needed to put some distance between myself and the problem (it dawned on me in the train on my way home). The pattern in this case needs to contain fewer or an equal number of letters for the year than the actual string to be parsed. The pattern “dd.MM.yy” interprets both the above examples as March 3rd, 2008.

For testing purposes I wrote a few lines of code to observe the behavior of the parse() method.

import java.text.*;
public class DateTest {
    private static final DateFormat parseFormat = new SimpleDateFormat("dd.MM.yy");
    private static final DateFormat formattingFormat = new SimpleDateFormat("dd.MM.yyyy");

    public static void main(String[] args) throws ParseException {

    private static void test(String dateString) throws ParseException {


01.04.2008 // obvious, due to default lenient behavior
Exception in thread "main" java.text.ParseException: Unparseable date: "3.3.xx08"
	at java.text.DateFormat.parse(
	at DateTest.test(
	at DateTest.main(

23. March, 2008

Eclipse/Subversive, ordinal not located in LIBEAY32.dll

Filed under: Software Development — frightanic @ 10:02

This blog now resides at It will be discontinued here…

I recently downloaded Eclipse 3.3 packaged with its new standard SVN plugin Subversive.

[Side note]
I’ve been using Subversive before for almost as long as it exist – it was way better than Subclipse from the beginning. In 2007 Eclipse fortunately chose it as the SVN plugin that will be shipped together with the Eclipse distribution. Therefore, Subclipse has to go through an incubator process during which things can get a bit shaky an confusion about version numbers arises.
[/Side note]
Whenever connecting to a SVN repository over SSL, Windows(!) throws a “The ordinal nnnn could not be located in the dynamic link library LIBEAY32.dll” error at me. The reason for this seems to be that Subversive comes with two versions of its JavaHL and native JavaHL connector: 1.4.5 and 1.5.0 alpha2. Both are enabled by default and both contain a LIBEAY32.dll, a different one however. Hence, I went to Help -> Software Updates -> Manage Configuration, disabled JavaHL 1.5.0 [alpha2] and Native JavaHL 1.5.0 [alpha2] (in that order!), and restarted Eclipse.

2. August, 2007

First steps with IBM/Rational Jazz

Filed under: Software Development — frightanic @ 01:43

This blog now resides at It will be discontinued here…

Erich Gamma gave a keynote at Jazoon ’07 presenting IBM/Rational Jazz (beta 1 Version). Jazz blew me away in an instant! Erich presented a platform with all the features I ever wanted for efficient, agile development.

In short, Jazz is like Eclipse with integrated repository, task planning, build engine. The first question of course is: why did they reinvent the wheel? Why does Jazz come with its own repository, task planner, build engine when there are good tools already available for that? Seems that true seamless integration was only possible if they started from scratch. Usually I’m allergic to vendor lock-in, but Jazz will make me throw my own principles over board.

So, I signed up for an account at, downloaded and installed Jazz, and started with the tutorial. Here’s my first impression:

  • server setup is peanuts, runs out of the box, platform support for Windows XP (???) and Red Hat Enterprise Linux, very good installation instruction
  • no setup needed at all for client, runs out of the box, Jabber setup seems dead easy (issue with Jazz/Jabber user mapping), very good installation instruction
  • I read the technical overview which starts with a nice motivation why one would/should use Jazz i.e. what its aims are
    • other IDEs (certainly Eclipse) can connect to the Jazz server and repository
    • server runs its services as WS with SOAP
    • there’s a client library that abstracts communication with server
    • server runs separate set of services for Web UI calls (AJAX!?)
    • a “Jazz Component” usually consist of two sets of plugins – one for the server and one for the client
    • Figure 4 showing platform components: yeah, yeah, yeah EXACTLY what I need
    • … stopped reading and went for the tutorial
  • wonderful integration of (iteration/milestone) planning and work items
    •   integration really is terrific, more powerful than for example Jira plugin for Eclipse
    •   BUT planning features not (yet) as powerful as Jira, which is just perfect for task planning and bug tracking
  • SCM (source control management) is totally new
    • private repository workspace per user!
    • if you check-in, the artifacts are only copied from the workspace to your private repository
    • only if you “deliver” to the stream (trunk or branch) they are made available to other team members
    • updating is called “accepting” change-sets from a stream
    • you also accept change-sets from other private repositories
    • this allows for light-weight collaboration of a group of developers without interfering with the rest of the team (general repository)
    • indirection might proove cumbersome in daily life…no, because check-in to your own repository can be configured to automatic
  • might take a while until folks will get used to all the new terms and their relationships: streams, components, workspaces; on the other hand, we’ve been dealing with that for years but in a more implict manner.
  • is the success of working with Jazz dependant on the “quality” of the people working with it? The tutorial guides you through all the basic steps and shows you how to do things right. What if you don’t associate a change set with a work item before delivering it to a stream? If you forget such steps, will you have to pay the price in that your setup becomes a mess after a while since you have many loose ends?
  • I see a danger of getting lost in the various views for pending changes, change-sets, work items, repository, etc. Each developer will have to find out which view he really needs, as you basically navigate from one to the other anyway.
  • the web UI is wonderful! It’s not just that it holds the same information as you would see in your Jazz client (i.e. Jazz Eclipse), but the information is presented with the same layout, fonts, colors, etc.
  • integrated build system
    • can be run locally from within Jazz if desired
    • nice wizard-based setup that generates Ant-script and properties
    • instant local test engine to run a build locally before having it run on the remote/shared Jazz build engine for the team
    • no predefined Maven(2) build setup provided, but hand-made templates can be used with the Jazz server
    • Jazz Ant tasks for repository communication (check-out, build artifact check-in)
    • it’s a big advantage when the build report can be linked with other editors in Eclipse. So, if there’s a stacktrace in build log, it is linked with the actual sources as if you’d see the stacktrace in own Eclipse console; same with JUnit tests
    • didn’t find information yet where the build reports can be found through the Jazz web interface

I want Jazz – for all my Java projects!

4. July, 2007

How Java exceptions can fool you

Filed under: Java,Software Development — frightanic @ 23:15

My blog stats clearly indicate that many visitors find my posts through search engines. What is mostly queried are solutions or hints for software problems. That’s why I’ll keep posting solutions to interesting problems.

While deploying a Struts based application on a co-worker’s Eclipse/Tomcat installation we were faced with a nice ActionServlet exception (org.apache.struts.action.ActionServlet abbreviated as ActionServlet):
javax.servlet.UnavailableException: Parsing error processing resource path
at ActionServlet.handleConfigException(
at ActionServlet.parseModuleConfigFile(
at ActionServlet.initModuleConfig(
at ActionServlet.init(

We knew that the path to struts-config.xml was correct, but we couldn’t get to the root of the problem. So, we started debugging ActionServlet#parseModuleConfigFile(). We found that the “real” exception was a SaxParseException due to “premature end of file”. That left us even more puzzled as struts-config.xml was a perfectly valid XML file.

So, we started to play around with that file. Erase the encoding declaration, remove certain segments, etc. Nothing helped. Then I discovered that the SaxParseException with the misleading message “premature end of file” carried a InvocationTargetException as its cause. Now that started to look interesting. That exception’s message brought me to the real problem: “Unsupported major.minor version“!

My co-worker had set up Eclipse to use a Java 5 JDK to compile his code, but had run Tomcat using a Java 1.4 version. Ok, this doesn’t necessarily cause problems unless you set the compiler’s compliance level to 1.5, which my co-worker had done.

27. June, 2007

Why ServletRequest#getRemoteAddr() returns

Filed under: Java,Software Development — frightanic @ 00:39

When I found the reason why my Servlet container returns the “wrong” remote address I had to smite my forehead – long and hard. As so often the container is right and I was simply on the wrong track. It’s soooo obvious, Jesus…

If you access your application using the URL


, you will get the remote address as (local host address i.e. loop back address). Instead, try accessing the URL using your system/server name to get the desired output


Yet another lesson learned I’ll never forget.

Next Page »

Blog at