The IndexSearcher is thread-safe. The QueryParser is *not*. From the JavaDocs for QueryParser....
Note that QueryParser is *not* thread-safe. So I'd guess you're using a single QueryParser across multiple threads. Just use a new one each time, they're not expensive... Best Erick On Jan 28, 2008 3:04 AM, Cam Bazz <[EMAIL PROTECTED]> wrote: > Hello, > > Is IndexSearcher ThreadSafe? I made a simple httpserver using grizzly as > described in > > http://jlorenzen.blogspot.com/2007/06/using-grizzly-to-create-simple-http.html > which submit queries to a single instance of indexsearcher and I get some > errors (when I query with more then one threads) such as: > > Jan 28, 2008 9:52:56 AM > com.sun.grizzly.http.DefaultProcessorTaskinvokeAdapter > SEVERE: processorTask.serviceError > java.lang.NullPointerException > at org.apache.lucene.queryParser.QueryParser.jj_scan_token( > QueryParser.java:1427) > at org.apache.lucene.queryParser.QueryParser.jj_3R_3(QueryParser.java > :1319) > at org.apache.lucene.queryParser.QueryParser.jj_3_1(QueryParser.java > :1313) > at org.apache.lucene.queryParser.QueryParser.jj_2_1(QueryParser.java > :1297) > at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java > :991) > at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java > :948) > at org.apache.lucene.queryParser.QueryParser.TopLevelQuery( > QueryParser.java:937) > at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java > :147) > at sys.GGSearcher.searchQuery(GGSearcher.java:70) > at sys.EmbeddedServer.service(EmbeddedServer.java:52) > at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter( > DefaultProcessorTask.java:599) > at com.sun.grizzly.http.DefaultProcessorTask.doProcess( > DefaultProcessorTask.java:530) > at com.sun.grizzly.http.DefaultProcessorTask.process( > DefaultProcessorTask.java:774) > at com.sun.grizzly.http.DefaultProtocolFilter.execute( > DefaultProtocolFilter.java:130) > at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter( > DefaultProtocolChain.java:102) > at com.sun.grizzly.DefaultProtocolChain.execute( > DefaultProtocolChain.java:78) > at com.sun.grizzly.http.SelectorThread$1.execute(SelectorThread.java > :637) > at com.sun.grizzly.ProtocolChainContextTask.call( > ProtocolChainContextTask.java:61) > at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:179) > Jan 28, 2008 9:52:56 AM > com.sun.grizzly.http.DefaultProcessorTaskinvokeAdapter > SEVERE: processorTask.serviceError > org.apache.lucene.queryParser.ParseException: Cannot parse 'test': > Encountered "<EOF>" at line 1, column 0. > Was expecting one of: > <NOT> ... > "+" ... > "-" ... > "(" ... > "*" ... > <QUOTED> ... > <TERM> ... > <PREFIXTERM> ... > <WILDTERM> ... > "[" ... > "{" ... > <NUMBER> ... > > > This error does not happen if I do searches one at a time. > > Best Regards, > -C.B. >