Expand my Community achievements bar.

SOLVED

Search and Promote OOTB component NullPointerException

Avatar

Level 2

[http://stackoverflow.com/questions/42446673/search-and-promote-null-pointer]

 

Using the provided OOTB Search & Promote components with an S&P service the following error is thrown when I try and search:

GET /content/Search/Results.html HTTP/1.1] org.apache.commons.httpclient.HttpMethodBaseGoing to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.GET /content/Search/Results.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service:Uncaught SlingExceptionjava.lang.NullPointerException: null at com.day.cq.searchpromote.xml.result.Pagination.getResultPages(Pagination.java:69)

So there's a null in the following code on the getResultPages call, in the results component.

 Pagination pagination = search.getPagination();if(pagination != null) {totalPages = pagination.getTotalPages();for (ResultPage resultPage : pagination.getResultPages()) {if (resultPage.isSelected()) {currentPageNumber = resultPage.getPosition();}}}

Does anyone know why this might be null? Even if I have no valid search results I'm assuming this should still provide me with a valid view of zero results.

 
1 Accepted Solution

Avatar

Correct answer by
Level 10

I worked with S&P where it used to return JSON and it was client side driven project.

But I would say, if you add null checks where you are getting this error. It should solve the issue.

View solution in original post

3 Replies

Avatar

Level 10

S&P might remove inner array when there are no results.

I have worked with S&P for AEM projects, Can you share the response you get when there are no result?

Thanks

Avatar

Level 2

Hi edubey, 

Thanks for getting back to me.

There is no response because it breaks on an internal server error.

Avatar

Correct answer by
Level 10

I worked with S&P where it used to return JSON and it was client side driven project.

But I would say, if you add null checks where you are getting this error. It should solve the issue.