Monday, January 29, 2007

NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream

when trying to send mail i get error: NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream

get mail.jar and put it on your classpath

Friday, January 26, 2007

Java: find nested balanced tags

I needed to parse out some divs from a html page, and java's regex cant do it. atleast when you have arbitrary number of nested balanced elements.


Use at your own risk.

Tuesday, January 16, 2007

UNIX: dd trick to speed up disk access times

This was stolen from the Lucene mailing list as a strategy to warm up an IndexSearcher:
Something like dd if=/path/to/index/foo.cfs of=/dev/null
Basically, force the data through the kernel preemptively, so FS caches it.
Run vmstat while doing it, and if the index hasn't been cached by the FS, you should see a spike in IO activity while dd is running.

source: (something in the middle of the thread)

Monday, January 15, 2007

java.lang.NoSuchFieldError:prohibited Lucene Highligher

java.lang.NoSuchFieldError: prohibited


You are using an old (pre 1.9) highlighter lib on a
1.9+ lucene. You need to pull the latest highlighter
sources from the svn repos, make a jar out of them and
use that inst

also, 'prohibited' referes to actual method param inside
of highlighter.

nice regex util class, replaceAll

Here is an example of what this does:
String result = new Rewriter("([0-9]+) US cents") {
public String replacement() {
long dollars = Long.parseLong(group(1))/100;
return "$" + dollars;
}.rewrite("5000 US cents");

prints>> $50


Wednesday, January 10, 2007 read past EOF on Lucene

This is the error: read past EOF

Lucene throws that error when you try to read an index.

The lucene index was most likely corrupted at some point. In my case, it broke during the ant's copy in the deployment.

Other pages say that it may be because the index uses a weird char set where chars may be bigger or smaller then what you think they are, so if you think they are 8 bits, and they are actually 7, you will read past EOF.