I’ve had an interesting problem with FileOutputChannel and RandomAccessFile from Java NIO.

If I understand the API correctly, it is enough to position(pos) on a FileOutputChannel and then use transferFrom

However transferFrom always returned 0. Then I used setLength on the RandomAccessFile where the FileOutputChannel was derived from and then it worked.

This was for Java 1.6 developer preview on OS X 10.4, maybe it is not even a Problem on other systems.

Maybe you know the situation: you are developing a web application using the Maven build system along with an application server like Tomcat or Jetty and a corresponding plugin (e.g. the all famous jetty-maven-plugin).

One of the coolest features of these containers is the hot-deployment.

However, every second time a hot deployment is executed, it crashes due to a PermGen space Exception or a similar OutOfMemoryException.

Read more…

When playing around with the positions of Windows in Java, I have found a nice Java function: setLocationByPlatform of the Window class enables you to let your JVM choose the position of a new Window. This means that all windows won’t be placed at x=0 and y=0 but will be overlapped according to what your platform thinks is nice.

Recently I stumbled across a problem with the rich:modalPanel component of the JBoss RichFaces component library, which didn’t want to show the data of a backing been.

Let’s assume the following scenario:
You have a DataTable with several rows. Each row contains a “See details…” button. This button will popup a modal panel using rich:componentControl and the panel is populated with data of a backing bean. This backing bean is filled with actual data by clicking our “See details…” button using a4j:actionparam

Read more…

For p300, I am currently using a Selector to check if I can read from or write to a socket.

However, this has lead me to a weird problem: select is called for at most 30 seconds and I get a timeout for writing even though this can’t really be and only happens with some OS combinations. I’ve found this thread in the Sun Forums and adapted my internal logic to the information from this forum thread:

Instead of always selecting for OP_WRITE when I want to write, I just try to write. If I was not able to write everything (that is, buffer.remaining () is bigger than 0) I select for OP_WRITE.

This seems to work fine.

I sometimes get this error in the J2EE (or JEE) module settings in the project options when changing modules. The settings will not even show what modules are chosen.

Read more…

I think I have spent at least 5 hours to get a selectManyCheckbox working properly in JSF. I was getting validation errors and other trouble.

However I have found a great source of information. Also, on some other websites you can read that you should use an array instead of a List for the getter/setter of the backing bean.

Maybe this helps…

I’ve recently spent some hours to track down a mysterious bug and I just couldn’t find it. Since my application is using a lot of Threads/Workers it came to my mind that a RuntimeException I did not catch could be the cause. I wrote a global handler for it and found where the problem was :)

Read more…

If you are getting an error that says “There is no ID/IDREF binding for IDREF” when validating an XML file you should check if an IDREF-typed attribute somewhere is pointing to an ID that is not defined anywhere yet.

A stupid thing about Java NIO and using blocking sockets is that the SO_TIMEOUT is not used anymore even if you set it. You may wonder why anyone will use blocking sockets with NIO? I am doing this in p300 because I want to use the increased performance of using FileChannel.transferFrom.

Read more…