problem:
when trying to send mail i get error: NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream
solution:
get mail.jar and put it on your classpath
http://java.sun.com/products/javamail/downloads/index.html
Monday, January 29, 2007
Friday, January 26, 2007
Java: find nested balanced tags
Problem:
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.
Solution:
Use at your own risk.
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.
Solution:
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)
http://www.gossamer-threads.com/lists/lucene/java-user/43418
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)
http://www.gossamer-threads.com/lists/lucene/java-user/43418
Monday, January 15, 2007
java.lang.NoSuchFieldError:prohibited Lucene Highligher
Problem:
java.lang.NoSuchFieldError: prohibited
at
org.apache.lucene.search.highlight.QueryTermExtractor
.getTermsFromBooleanQuery(QueryTermExtractor.java:91)
Solution:
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
elliotth.blogspot.com/java-implementation-of-rubys-gsub.html
Here is an example of what this does:
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");
System.out.println(result);
prints>> $50
nice!
Wednesday, January 10, 2007
java.io.IOException: read past EOF on Lucene
Problem:
This is the error:
java.io.IOException: read past EOF
Lucene throws that error when you try to read an index.
Solution:
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.
This is the error:
java.io.IOException: read past EOF
Lucene throws that error when you try to read an index.
Solution:
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.
Subscribe to:
Posts (Atom)