Extreme Java When vanilla Java is not enough


Changing HSQLDB in-process database default password

HSQLDB is not the kind of database I can use in enterprise systems (with terabytes of data), but it is specially useful if I need a simple RDBMS to small (or temporary) databases.
While trying it with Glassfish, I got a big problem: if you create an in-process database (using "jdbc:hsqldb:mem" or "jdbc:hsqldb:file" or "jdbc:hsqldb:res"), HSQLDB creates a default user named "SA" with an empty password. But Glassfish does not accept data sources without passwords (I get a "No PasswordCredential found").
To solve this, I grab the HSQLDB sources and changed the org.hsqldb.Database class. The "reopen" method has the following command:

if (isNew) {

I just changed it to:

if (isNew) {
    "CREATE USER " + urlProperties.getProperty("user") +
    " PASSWORD \"" + urlProperties.getProperty("password") +
    "\" ADMIN");

Compiling with "ant jar" (in build dir), the new hsqldb.jar will now allow you to create the user based on the credentials passed as login. But this will only work if you compile with a JDK 5, because a lot of methods required by JDBC in JDK 6 are implemented by throwing UnsupportedOperationException.

For some reason, Glassfish and HSQLDB with in-process only works with OpenJPA. I've tryed with Hibernate and TopLink, with really strange results. If I find a solution, I'll post later.


Java SCBCD 5.0 Certification

I am strudying for the SCBCD certification, and I realized there is almost no free material about it. I found this website and, IMHO it is an incredible source of information.
They also have some materials for other certifications (SCJP, SCWCD, etc), too, but I did not read them yet.


Adding special chars to NetBeans action name

This one I posted in NetBeans mailing lists. If you want to show a special char (like a slash - "/") in the action display name (i.e. in the way your user will see it), the right way is to pass it to the AbstractAction constructor (just like the templates of NetBeans):

public class SpecialCopyPasteAction extends AbstractAction {
  public SpecialCopyPasteAction() {
  public void actionPerformed(ActionEvent evt) {
    // TODO: Implement it

And, in Bundle.properties:

CTL_SpecialCopyPasteAction=Special Copy/Paste

Remember that the action name in layer.xml is mapped to a system file name. You cannot put a "/" on file names, even on Windows. This is one of the reasons NB filesystem has the localization feature.


JBossAS + JBossWS + JDK 6 = problems

Years ago, a lot of applications did not support JDK 5, even with the incredible range of new features. Today, the history repeats itself with JDK 6. A lot of applications do not support it. For my surprise, I added a big one to the list: JBoss.

How did I found it? By publishing a webservice using JBossWS (included in JBossAS). Deployment works, but when I consume the WS, I got this exception:

java.lang.UnsupportedOperationException: setProperty must be overridden by
all subclasses of SOAPMessage

After researching it on Google, I found this bug report. They tell JBoss is not supported on JDK 6, but, since I follow the "upgrade-or-bust" philosofy, I decided to put it to work.

It was pretty simple (on JBoss 4.2.2GA): grab a copy of "jboss-saaj.jar" from "server/default/lib" and copy it to "JBOSS_HOME/lib/endorsed". Works like a charm!