Issue in SimpleSearch.class | Community
Skip to main content
Nandujee
October 16, 2015
Solved

Issue in SimpleSearch.class

  • October 16, 2015
  • 6 replies
  • 1444 views

Hi there,

I tried to use the simpleSearchto achieve the  search functionality

When I try to use the below one.

slingRequest.getResource().adaptTo(SimpleSearch.class);

I got nullpointer exception.

Kindly guide me to resolve the issue. 

Thanks

Nanda

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Lokesh_Shivalingaiah

Make sure you have included the 'cq-search' dependency in your project

6 replies

Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
October 16, 2015

Make sure you have included the 'cq-search' dependency in your project

smacdonald2008
October 16, 2015

Why not use QueryBuilder API instead of SimpleSearch? 

Lokesh_Shivalingaiah
October 16, 2015
<dependency><groupId>com.day.cq</groupId><artifactId>cq-search</artifactId><version>5.5.4</version></dependency>
Nandujee
NandujeeAuthor
October 16, 2015

Thanks for your reply.

Dependency is already exist in my POM.xml.

I can import the SimpleSearch class in my code. 

When I try to print  'slingRequest.getResource()' in the console. I can see the object reference.

But when I try with adaptTo(SimpleSearch.class). Here I got a NullpointerException.

FYI, I am using AEM 6.0.

Thanks

Nanda

Feike_Visser1
Adobe Employee
Adobe Employee
October 16, 2015

do you have a stacktrace in the error.log file?

Lokesh_Shivalingaiah
October 16, 2015

Can you give me the usecase for adapting SimpleSearch ?