Sightly / WCMUse error. | Community
Skip to main content
Stipo42
October 16, 2015
Solved

Sightly / WCMUse error.

  • October 16, 2015
  • 4 replies
  • 2691 views

Hi, I'm trying to create a WCMUse java object at the component level to use with sightly, and I keep getting the following error:

org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier: AEMUser

The idea is to wrap the jackrabbit user class for use by sightly, my company does a lot with security groups and prefer to do things on the code level vs the author targeting level (our authors don't understand targeting)

Anyway, here is the class that wraps the jackrabbit User class:

package apps.AEMUPGRADE.components.aemUser; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.Group; import com.adobe.cq.sightly.WCMUse; public class AEMUser extends WCMUse{ private String username; private User user; public AEMUser(String username){ this.username = username; } @Override public void activate() throws Exception { username = get("username", String.class); user = getResource().adaptTo(User.class); } public User getUser(){ return user; } public String getUsername(){ return username; } public java.util.Iterator<Group> getUserGroups(){ try{ if(user!=null){ return user.memberOf(); } }catch(javax.jcr.RepositoryException jre){ //Hold off for now } return null; } }

I will likely move this into a bundle but just wanted to get it working first.
Here is my sightly code:

 

<div class="${properties.cssClass}"> Hello, ${request.remoteUser} </div> <p>You belong to the following groups</p> <ul data-sly-use.aemUser="AEMUser"> <li>${user.username}</li> <li> <ul data-sly-list.child="${user.userGroups}"> <li>${childList.index}:${child.iD}</li> </ul> </li> </ul>

And here are the paths:
/apps/AEMUPGRADE/components/aemUser/aemUser.html
/apps/AEMUPGRADE/components/aemUser/AEMUser.java
 

I followed all the examples to make this, not sure what I did wrong, I keep going over and over it but it doesn't seem to want to register AEMUser as a sightly object.

Am I missing something?

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 PaulMcMahon

You issue is the constructor. Either remove your constructor, or add a no arg constructor that just calls super. 

4 replies

PaulMcMahonAccepted solution
Level 8
October 16, 2015

You issue is the constructor. Either remove your constructor, or add a no arg constructor that just calls super. 

senolt7451613
October 16, 2015

Hi, it looks like a java problem with upper case package names. Can you try convert this path /apps/AEMUPGRADE/components/aemUser/  all to lower case and then change 

  1. package apps.AEMUPGRADE.components.aemUser; to
  2. package apps.aemupgrade.components.aemuser;

that should do the trick

Stipo42
Stipo42Author
October 16, 2015

Hm, I removed the constructor and still get the  No use provider could resolve identifier exception...

Same thing when putting in a default with super();

 

Any other thoughts? I even tried giving it the fully qualified name.

Is there maybe a special nodetype I need for it to register?

Stipo42
Stipo42Author
October 16, 2015

As a follow up, I got this to work by killing the generated java class files in the /var/classes/<id> folder

There were old versions of my java class there which were conflicting with the correct version, from when I thought my package naming was wrong.

Thanks for the help, orotas has the correct solution.