Expand my Community achievements bar.

SOLVED

CugSupport reference not resolved

Avatar

Level 4

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?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

4 Replies

Avatar

Level 5

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.

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 4

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?

Avatar

Level 10

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.