Java Use-API: No use provider could resolve identifier | Community
Skip to main content
October 16, 2015
Solved

Java Use-API: No use provider could resolve identifier

  • October 16, 2015
  • 10 replies
  • 9388 views

Hi everybody,

I'm experimenting with the new Java Use-API [1] but I'm having trouble getting it to work.

  1. I have a component here: /apps/abc/components/modular/C03-topbanner/
  2. Following the instructions, I put my .java file here: /apps/abc/components/modular/C03-topbanner/C03_topbanner.java
  3. The package name in the java file is: apps.abc.components.modular.c03_topbanner (replacing the - with _ as described)
  4. The class name is C03_topbanner
  5. Within my sightly file (/apps/abc/components/modular/C03-topbanner/C03-topbanner.html) I'm calling it like so: data-sly-use.topbanner="c03_topbanner"
  6. This gets me the extension: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier: c03_topbanner
  7. I've tried a few variation with file/package/class names but it never seems to work... The way I understand it from the docs is that just the package name has to be the same as the use class

Any ideas what I could be missing?

[1] http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-java.html

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 knennig

The data-sly-use attribute uses the class name for java files, which are case sensitive. Looks like you used 

data-sly-use.topbanner="c03_topbanner"

Rather than

data-sly-use.topbanner="C03_topbanner"

Hopefully that fixes your error.

10 replies

knennigAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

The data-sly-use attribute uses the class name for java files, which are case sensitive. Looks like you used 

data-sly-use.topbanner="c03_topbanner"

Rather than

data-sly-use.topbanner="C03_topbanner"

Hopefully that fixes your error.

Level 8
October 16, 2015

Does you class implement the WCMUse interface, and does it have an activate method? I have seen where that was an issue that generated the same error. 

October 16, 2015

Yes. Here's my dummy code so far:

package apps.abc.components.modular.c03_topbanner; import com.adobe.cq.sightly.WCMUse; import com.day.cq.wcm.api.components.DropTarget.CSS_CLASS_PREFIX; public class C03_topbanner extends WCMUse { private String cssClass; @Override public void activate() throws Exception { cssClass = DropTarget.CSS_CLASS_PREFIX; } public String getCssClass() { return cssClass; } }
October 16, 2015

I got it to work now. I'm actually not sure what solved it in the end because I was pretty sure I had tested all these combinations. I changed the package and class name to "C03_topbanner". 

b7wilso
Level 3
October 16, 2015

I am having a similar issue was wondering if someone could help.

    Component is located in /apps/global-web/components/content/relatedlinks/
    .java located in /apps/global-web/components/content/relatedlinks/MFPF.java (which extends WCMUse and I Override activate() )
    package name is apps.global_web.components.content.relatedlinks
    class name is MFPF
    sightly file (/apps/global-web/components/content/relatedlinks/relatedlinks.html) calls the java class as such: data-sly-use.mfpf="MFPF"

I actually shortened the class name down to MFPF in case there was some sort of weird length limit and have tried multiple variations.

Any thoughts?

October 16, 2015

Have you tried commenting out everything to narrow it down? I've had the same error message one time and it turned out there was just a java error that never showed up anywhere..

Feike_Visser1
Adobe Employee
Adobe Employee
October 16, 2015

Do you see your class to be compiled in /var/classes?

Otherwise I would try to move it to an OSGi-bundle to see if that works, then you know the Use-class is fine.

b7wilso
Level 3
October 16, 2015

Thanks for the responses guys.  I have stripped it down to bare bones to try and get it to compile so this is what I have in the class currently:

package apps.global_web.components.content.relatedlinks

import com.adobe.cq.sightly.WCMUse;

public class MFPF extends WCMUse {
    private String testVal;

    @Override
    public void activate() throws Exception {
        //testVal = "I can write a class that actually works!";
    }

    /*public String getTestVal() {
        return testVal;
    }*/
}

I just checked var/classes and no I do not see anything in there.  Would it be in/near the root or would it setup a similar folder structure to the one that is existing in there (in this class's case apps/global_web/etc...) ?

b7wilso
Level 3
October 16, 2015

OK, so we found the error before dropping it over in an OSGi bundle, no semi-colon on the package.blush

Feike_Visser1
Adobe Employee
Adobe Employee
October 16, 2015

Nice one! :-) Great that this is now resolved.