Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

LikeMe component throws NPE #2

Open
cons0l3 opened this issue Oct 22, 2016 · 1 comment
Open

LikeMe component throws NPE #2

cons0l3 opened this issue Oct 22, 2016 · 1 comment

Comments

@cons0l3
Copy link

cons0l3 commented Oct 22, 2016

Cool demo, especially for a beginner like me.

I am running org.apache.sling.launchpad-8.jar unmodified and fresh install on jdk7. I followed the steps to run your sample/tutorial. I work on unmodified sample data and execute a "Like me" operation on the "http://localhost:8080/content/adaptto/2015/day1/rookie-session.html"

The LikeMe component in line 67 calls
ValueMap writeProps = request.getResource().adaptTo(ModifiableValueMap.class);
which leaves the writeProps = NULL. Consequently writeProps.get(...) in line 67 throws NPE. see below.

If I execute request.getResource().adaptTo(ValueMap.class) instead, I get a beautiful ValueMap (non-null!).

I have checked for security issues (like administrative resolver...) but was unlucky.

Please advice.

Exception:
`Internal Server Error (500)

The requested URL /content/adaptto/2015/day1/rookie-session.likeme.html resulted in an error in org.adaptto.rookie.demo.components.LikeMe.

Exception:

java.lang.NullPointerException
at org.adaptto.rookie.demo.components.LikeMe.updateLikeCounter(LikeMe.java:67)
at org.adaptto.rookie.demo.components.LikeMe.doPost(LikeMe.java:48)
at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:149)
[...]

@sschlick
Copy link
Contributor

Thank you for your thumbs up!

If you login first at:
http://localhost:8080/.explorer.html#
then the adaption to the ModifiableValueMap should work.

Feel free to contribute a specific handling to our example.

Cheers
Sebastian

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants