PermGen Errors

Keep getting PermGen out of memory errors? This is very prevalent during debugging as many platforms, such as JBoss, use up the space by re-creating classes with different classloaders (which is what you want when you’re debugging and restarting applications).

There is a relatively easy fix though… increase the size allocated by the JVM on startup.


java -XX:PermSize=64m -XX:MaxPermSize=256m com.elegando.MainClass

You can obviously add those same parameters to your JBoss application server launcher.

Search with Lucene

The Apache project Lucene has gotten a lot of attention as a good open source search platform.  Any one who needs search capabilities should consider Lucene in their due diligence.

Fixing Fixed-Width Text Files

To remove the end line characters in a text file that has every line truncated at 80 chars…

perl -pi -e ‘s/(….+)\r\n/$1 /’ filename.txt
perl -pi -e ‘s/\n/\n\n/’ filename.txt

Then open in Write –> copy and paste into word.

Replace Text

Here’s a quick one-liner for perl… replace every occurance of “boring” with “fun”:

perl -pi.bak -e ‘s/boring/fun/’ filename.txt

Recursive Search

I usually use Windows Explorer to find something recursively within a folder hierarchy… but sometimes it doesn’t work based on the file types. When that happens, I fall back to this find + grep combination (available with cygwin utils):

find . -type f -exec grep needle {} \; -print

It looks for the word “needle” in any file under the current directory.

The “-type f” option says, only find files.  The “{}” is replaced with the filename (so you can do “grep -i -XYZ needle {}” if you needed to…

Windows Time Synch

Windows nicely ships with a little utility that updates your system time with an internet server so that the clock won’t skew over time. This is a Pretty Good Idea, but alas, it went away several months ago.

The built-in servers time.windows.com and time.nist.gov no longer respond to requests to get the current/correct time.

As I am not the only person to identify this problem, there is an online list of other time servers that you can set windows to synch with. Just double-click on the clock in your task bar, and enter a new server name in the Internet Time tab:

Time Synch Screenshot

JBoss as a Service on Windows

Want to run JBoss as a Windows Service? The old suggested solution was to use Java Service Wrapper, but the Wiki states it is no longer recommended. An alternative recently surfaced…

The JBossWeb Project includes a native launcher that allows JBoss AS to be installed as a windows service. The tool uses your run.bat as the launcher, so you can make any runtime modifications (vm flags, etc.) to the batch file.

Review the README file in the download for additional information.

JSF Tricks

Here are a few tricks over at the MyFaces Wiki:

  • Executing an action when a drop-down value changes
  • Executing an action when the enter key is pressed

The latter is helpful when the Ajax4JSF components stop the enter key from submitting a form / executing an action.

The rest of the wiki is a little bit sparse, but still has some good topics.