CugSupport reference not resolved | Community
Skip to main content
Level 4
October 16, 2015
Solved

CugSupport reference not resolved

  • October 16, 2015
  • 4 replies
  • 1296 views

I'm trying to use a reference to CugSupport service into an osgi component, like these:

import com.day.cq.auth.impl.CugSupport; ... @Component @Service public class MyComponentImpl implements MyComponent { @Reference private CugSupport cugSupport; ... private String getCugRootLoginPage(final HttpServletRequest request) { // check for a CUG final CugSupport cugSupport = this.cugSupport; if (cugSupport != null) { return cugSupport.getLoginPage(request); } return null; } }

I added this maven dependency to my pom:

            <dependency>
                <groupId>com.adobe.granite</groupId>
                <artifactId>com.adobe.granite.auth.authhandler</artifactId>
                <version>5.6.2</version>
                <scope>provided</scope>
            </dependency>

which is the only one I found on Adobe maven repository.

When I try to install my bundle into my AEM instance I have this exception:

05.02.2015 09:10:53.173 *WARN* [OsgiInstallerImpl] Failure loooking up method bindResourceResolverFactory(org.osgi.framework.ServiceReference) Assuming no such method. (java.lang.NoClassDefFoundError: com/day/cq/auth/impl/CugSupport) java.lang.NoClassDefFoundError: com/day/cq/auth/impl/CugSupport

I am using AEM 6 + SP2.

Do you know how can I fix this error?

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 joerghoh

This will not work, as this interface is not exported by the OSGI bundle. In AEM 6.0 (the version I have handy right here) I have the bundle com.day.cq.auth.authhandler exporting nothing. And I really doubt, that this has changed with SP1.

Where have you the reference to this service? It isn't a public API.

kind regards,
Jörg

4 replies

Level 5
October 16, 2015

boser87 wrote...

I'm trying to use a reference to CugSupport service into an osgi component, like these:

  1. import com.day.cq.auth.impl.CugSupport;
  2.  
  3. ...
  4.  
  5. @Component
  6. @Service
  7. public class MyComponentImpl implements MyComponent {
  8.  
  9. @Reference
  10. private CugSupport cugSupport;
  11.  
  12. ...
  13.  
  14. private String getCugRootLoginPage(final HttpServletRequest request) {
  15. // check for a CUG
  16. final CugSupport cugSupport = this.cugSupport;
  17. if (cugSupport != null) {
  18. return cugSupport.getLoginPage(request);
  19. }
  20.  
  21. return null;
  22. }
  23.  
  24. }

I added this maven dependency to my pom:

            <dependency>
                <groupId>com.adobe.granite</groupId>
                <artifactId>com.adobe.granite.auth.authhandler</artifactId>
                <version>5.6.2</version>
                <scope>provided</scope>
            </dependency>

which is the only one I found on Adobe maven repository.

When I try to install my bundle into my AEM instance I have this exception:

 
  1. 05.02.2015 09:10:53.173 *WARN* [OsgiInstallerImpl] Failure loooking up method bindResourceResolverFactory(org.osgi.framework.ServiceReference) Assuming no such method. (java.lang.NoClassDefFoundError: com/day/cq/auth/impl/CugSupport)
  2. java.lang.NoClassDefFoundError: com/day/cq/auth/impl/CugSupport

I am using AEM 6 + SP2.

Do you know how can I fix this error?

 

Your code not giving any issue during build in AEM6+SP1 as i executed. But your error seem missing dependency. Check .m2 folder whether it exists.  Try Re-Import maven dependencies using IDE.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

This will not work, as this interface is not exported by the OSGI bundle. In AEM 6.0 (the version I have handy right here) I have the bundle com.day.cq.auth.authhandler exporting nothing. And I really doubt, that this has changed with SP1.

Where have you the reference to this service? It isn't a public API.

kind regards,
Jörg

boser87Author
Level 4
October 16, 2015

I can resolve the dependency both locally and while deploying on the AEM instance.

Maybe the problem is that the service I'm trying to use is declared as private into the bundle POM?

<Private-Package>com.day.cq.auth.impl.*</Private-Package>

The strange thing here is that the service interface is placed under impl package and thus not exported...

But how am I supposed to rertrieve the CUG's login page without this?

smacdonald2008
Level 10
October 16, 2015

Can you point to the online resource that you are following to perform this task? I assume that you are following some content posted somewhere.