You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gerald <ge...@topproducer.com> on 2010/05/31 23:45:24 UTC
NPE error when extending DefaultSolrHighlighter
I was looking at solr-386 and thought I would try to create a custom
highlighter for something I was doing.
I created a class that looks something like this:
public class CustomOutputHighlighter extends DefaultSolrHighlighter {
@Override
public NamedList doHighlighting(DocList docs, Query query,
SolrQueryRequest req, String[] defaultFields) throws IOException {
NamedList highlightedValues = super.doHighlighting(docs,
query, req, defaultFields);
// do more stuff here
return highlightedValues
}
}
and have replaced the <highlighting> line in my solrconfig xml so that it
looks something like this:
<highlighting class="com.xxxxxxx.solr.highlight.CustomOutputHighlighter">
and left all the existing default highlighting parameters as-is
The code compiles with no problem, and should simply perform the normal
highlighting (since all I am doing is calling the original doHighlighting
code and returning the results). However, when I start Solr, I get an NPE
error:
java.lang.NullPointerException
at
org.apache.solr.highlight.DefaultSolrHighlighter.init(DefaultSolrHighlighter.java:75)
at
org.apache.solr.core.SolrCore.createInitInstance(SolrCore.java:437)
at org.apache.solr.core.SolrCore.initHighLighter(SolrCore.java:612)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:558)
at
org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:137)
at
org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:83)
at
org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at
org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:594)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
at
org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
at
org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
at org.mortbay.jetty.Server.doStart(Server.java:210)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:929)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mortbay.start.Main.invokeMain(Main.java:183)
at org.mortbay.start.Main.start(Main.java:497)
at org.mortbay.start.Main.main(Main.java:115)
It doesn't seem to even call my custom highlighter (I put a breakpoint in
which did not get hit). Any ideas re what I am doing wrong??
If I use the default highlighter, I don't get this error and have no
problems
I am using a copy of 1.5.0-dev solr ($Id: CHANGES.txt 906924 2010-02-05
12:43:11Z noble $)
thanks for any advice
--
View this message in context: http://lucene.472066.n3.nabble.com/NPE-error-when-extending-DefaultSolrHighlighter-tp859670p859670.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: NPE error when extending DefaultSolrHighlighter
Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
(10/06/01 6:45), Gerald wrote:
> I was looking at solr-386 and thought I would try to create a custom
> highlighter for something I was doing.
>
> I created a class that looks something like this:
>
> public class CustomOutputHighlighter extends DefaultSolrHighlighter {
> @Override
> public NamedList doHighlighting(DocList docs, Query query,
> SolrQueryRequest req, String[] defaultFields) throws IOException {
> NamedList highlightedValues = super.doHighlighting(docs,
> query, req, defaultFields);
>
> // do more stuff here
>
> return highlightedValues
> }
> }
>
> and have replaced the<highlighting> line in my solrconfig xml so that it
> looks something like this:
>
> <highlighting class="com.xxxxxxx.solr.highlight.CustomOutputHighlighter">
>
> and left all the existing default highlighting parameters as-is
>
> The code compiles with no problem, and should simply perform the normal
> highlighting (since all I am doing is calling the original doHighlighting
> code and returning the results). However, when I start Solr, I get an NPE
> error:
>
>
Try to put a constructor that has an argument SolrCore:
public CustomOutputHighlighter(SolrCore core){
super(core);
}
Koji
--
http://www.rondhuit.com/en/