问题描述
Servlet.service() for servlet jsp threw exception java.lang.NullPointerExceptionat org.apache.lucene.search.highlight.QueryTermExtractor.getTerms(QueryTermExtractor.java:125)at org.apache.lucene.search.highlight.QueryTermExtractor.getTerms(QueryTermExtractor.java:96)at org.apache.lucene.search.highlight.QueryTermExtractor.getTerms(QueryTermExtractor.java:109)at org.apache.lucene.search.highlight.QueryTermExtractor.getTerms(QueryTermExtractor.java:48)at org.apache.lucene.search.highlight.QueryScorer.<init>(QueryScorer.java:50)at org.apache.jsp.results_jsp._jspService(results_jsp.java:244)at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)at java.lang.Thread.run(Thread.java:595)
解决方案
做如下判断:Document doc = (Document) hits.doc(j);String ct_title = doc.get("ct_title");if (ct_title != null) {TokenStream tokenStream = analyzer.tokenStream("ct_title",new StringReader(ct_title));ct_title = highlighter.getBestFragment(tokenStream,ct_title);ct_title = ct_title == null ? doc.get("ct_title"): ct_title;}
解决方案二:
你的jar包放对地方了吗,怎么像没找到 jar一样,断点调试一下
解决方案三:
看看传入的值是否为空?判断一下!
解决方案四:
这就要看具体的太吗了? 我想大多都是一些不注意的地方这个异常很多的,也很频繁的.
解决方案五:
明显空指针异常错误,打个断点跟踪一下,看看哪出来的,解决应该很容易,lz这个问题怎么感觉好像是不太了解java呢
解决方案六:
加高亮时进行非空判断,为空就跳过,不为空就进行高亮处理~~~我觉得也是这个问题 你检查一下空指针异常一般是穿值为空了
解决方案七:
加高亮时进行非空判断,为空就跳过,不为空就进行高亮处理~~~
解决方案八:
当你要高亮某字段数据时,这列没有包含你搜索的关键词,所以会返回空。
解决方案九:
该org.apache.lucene.search.highlight.QueryTermExtractor对象为空!请仔细检查
解决方案十:
把你用的的QueryTermExtractor代码贴出来,我的版本跟你不一样NullPointerException基本上是最容易解决的问题...