Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adapter vs Adaptables w.r.t request.adaptTo(Interface.class)


Level 2

Hi Team , 


We have a use -case where in we are using OOTB and with 1-2 additional fields in it.

So we have used the same logic on our project.  functionality works fine.

But when it comes to its Junits . its fails to request.adaptTo(

All the time it gives null.


-> I debugged it and see adapter and adaptable is getAdapter(adaptable,type) it fails.

final Map<String ,List<AdapterFactoryDescription>> factories = getAdapterFactories(adaptable.getClass());

factories.get(type.getName)); this is giving null and at code print 

log.debug("No Adapter factory found to map {} to  {}, adaptable is slinghttprequest, and type is interface SocialMediaHelper..


Same Code as in complete OOTB when I check it works in vanilla instance. 


What am I missing here.. what should give as adapter and adaptable to make this succesfull request.adapTo(SocialMediaHelper.class)


Please help on this .. 

4 Replies


Level 2

Hi Sravan,


I did try that same output. : Null I get both the ways shared below.

request.adaptTo(SocialMediaHelper.Class)   or request.adaptTo(SocialMediaHelperImpl.Class) 


thanks for your response


Level 2

Hi Anmol,

I can surely try that.

But as I read the article you shared ,there are still open question and people did say its did not adapt Successfully .. Specially when a OOTB component is extended.