lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Moran <>
Subject Re: Index Path in WAR
Date Mon, 05 May 2003 00:38:10 GMT
Hi Jason,
    This may not be the best solution and may differ
from your situation if your index is read/write (mine
isn't).  But hey, it works for me.  How I got around
the problem was first to Jar up the index.  I Jarred
it up uncompressed for speed.  I then subclassed
Directory.  I called it JarDirectory.  I made
JarDirectory's constructor use
ClassLoader.getResource() to find the Jar and then
create a java.util.jar.JarFile from it.  The methods I
overrode in Directory (e.g., list(), fileExists(),
etc.) use the JarFile as appropriate.  After I
debugged that class all I had to do was create an
instance of JarDirectory and pass it to
IndexSearcher's constructor.  My searches then went
against the Jar file.  As long as the Jar is in the
classpath -- which you can bundle with your web app
and set a classpath to in your manifest file -- it
works.  That allows you to bundle the index with the
web app and avoid hard-coding a path to it.


P.S. Unfortunately, I can't provide the source to
JarDirectory as it is not mine to give.  But it didn't
take long to write and was less than 400 lines long. 
Maybe someone else on the mailing list can point you
to a better concrete example.

--- wrote:
> List,
> I'm having problems using an absolute path to the
> index directory when my web application is deployed
> in a WAR file.  The absolute path changes depending
> on the server.  Is there a way to either dynamically
> determine an absolute path to the index directory or
> to use relative pathing?
> Thanks in advance,
> Jason
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message