On Mon, Jun 08, 2020 at 09:16:17AM -0700, R W wrote:
> I am reaching out to ask for a second pair of eyes on this custom servlet
> that I'm migrating from DSpace JSPUI x5.9 to x6.3. The servlet builds and
> deploys without any issues but does not return a response from the solr
> query when the servlet URL is requested. The goal of this servlet is to
> return json data about deposits that have been recently viewed, the
> original solr query is in line 76. The logs don't indicate a solr response
> is returned at all, the last log is at line 89 and doesn't go past line 93
> where the response value is assigned. If anyone can spot anything I've
> missed or have some feedback about another approach, that would be greatly
> appreciated. Thank you for reading.
>
> Servlet
> 60 public class SolrStatsServlet extends DSpaceServlet
> 61 {
> 62 /** log4j category */
> 63 private static Logger log =
> Logger.getLogger(SolrStatsServlet.class);
> 64 private HandleService handleService;
> 65 private ItemService itemService;
> 66 // private static final String RESOURCE_TYPE_FIELD =
> "search.resourcetype";
> 67 private HttpSolrServer solr = null;
> 68
> 69 protected void doDSGet(Context context, HttpServletRequest request,
> 70 HttpServletResponse response) throws ServletException,
> IOException,
> 71 SQLException, AuthorizeException {
> 72
> 73 handleService =
> HandleServiceFactory.getInstance().getHandleService();
> 74 itemService =
> ContentServiceFactory.getInstance().getItemService();
> 75
> 76 // Original solr query -
> 'select?indent=on&start=0&rows=10&q=type:2&fq=-isBot:true&fq=statistics_type:view&sort=time+desc'
> 77 QueryResponse solrResponse = null;
> 78
> 79 try {
> 80
> 81 log.info("Debug 1");
> 82 SolrQuery solrQuery = new SolrQuery().setQuery("type:2");
> 83
> 84 solrQuery.addFilterQuery("-isBot:true");
> 85 solrQuery.addFilterQuery("statistics_type:view");
> 86 solrQuery.addSortField("time", SolrQuery.ORDER.desc); //
> sort by time
> 87 solrQuery.setRows(10);// 10 results max
> 88 log.info("Debug 2");
> 89 log.info(solrQuery);
> 90
>
> //q=type%3A0&fq=-isBot%3Atrue&fq=statistics_type%3Aview&sort=time+desc&rows=10
> 91
> 92 // solrResponse = solr.query(solrQuery);
> 93 solrResponse = solr.query(solrQuery,
> SolrRequest.METHOD.GET);
> 94 log.info("Debug 3");
> 95
> 96 } catch (SolrServerException e) {
> 97 log.info("Debug 4 - ERROR");
> 98 log.error("Solr failed to return docs for home page map: "
> + e.getMessage());
> 99 return;
> 100 }
> 101
> 102 log.info("Debug 5");
> 103 SolrDocumentList docList = solrResponse.getResults();
> 104 log.info("Debug 6");
>
>
> 136 }
> 137
> 138 protected void doDSPost(Context context, HttpServletRequest request,
> 139 HttpServletResponse response) throws ServletException,
> IOException,
> 140 SQLException, AuthorizeException
> 141 {
> 142 // Treat as a GET
> 143 doDSGet(context, request, response);
> 144 }
>
>
>
> Dspace.log file
>
> 2020-06-08 11:55:56,314 INFO org.dspace.app.webui.servlet.SolrStatsServlet
> @ Debug 1
> 2020-06-08 11:55:56,315 INFO org.dspace.app.webui.servlet.SolrStatsServlet
> @ Debug 2
> 2020-06-08 11:55:56,315 INFO org.dspace.app.webui.servlet.SolrStatsServlet
> @
> q=type%3A2&fq=-isBot%3Atrue&fq=statistics_type%3Aview&sort=time+desc&rows=10
> 2020-06-08 11:55:56,315 WARN org.dspace.app.webui.servlet.DSpaceServlet @
> anonymous:session_id=09DCF4D40B91772CB2F26D8F645148E5:ip_addr=142.150.192.3:general_jspui_error:java.lang.NullPointerException
> java.lang.NullPointerException
> at
> org.dspace.app.webui.servlet.SolrStatsServlet.doDSGet(SolrStatsServlet.java:93)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You have a NullPointerException, probably because 'solr' is set to null at line 67 and is never set to a reference afterward. -- Mark H. Wood Lead Technology Analyst University Library Indiana University - Purdue University Indianapolis 755 W. Michigan Street Indianapolis, IN 46202 317-274-0749 www.ulib.iupui.edu -- All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/ --- You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/20200609122206.GA21952%40IUPUI.Edu.
signature.asc
Description: PGP signature
