error Handler | Community
Skip to main content
Level 3
October 16, 2015
Solved

error Handler

  • October 16, 2015
  • 11 replies
  • 2482 views

I'm working with handler. I'm trying to use the slingRepository.  However, when I added to my class It's not deploying my handler and its not showing any error.

Any idea?

@Component(
        metatype = true,
        immediate = false
)
@Service
public class MyAuthenticationHandler extends DefaultAuthenticationFeedbackHandler implements AuthenticationHandler {

        
@Reference
 

private SlingRepository slingRepository;

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 Premkarthic-7WP

Avalers,

As a workaround you can get the service reference for sling repository inside activate method using component context as shown below.

@Service
public class TestAuthHandler extends DefaultAuthenticationFeedbackHandler implements AuthenticationHandler
{


    private SlingRepository repo;

    protected void activate(ComponentContext context) {
    
     try {

           BundleContext bundleContext = FrameworkUtil.getBundle(TestAuthHandler.class).getBundleContext();
           ServiceReference factoryRef = bundleContext.getServiceReference(SlingRepository.class.getName());
           repo = (SlingRepository) bundleContext.getService(factoryRef);


        } catch (Exception e) {
            
        }
        
    
        }.........

 

Hope this will work fine for you. Tested on 5.5/6.0. 

Note : I also faced the same issue some long time back when i tried to use sling repository reference inside service. Still debugging on that.

Thanks,

Karthi

11 replies

avalersAuthor
Level 3
October 16, 2015

I resolved. :) You were right!

The problem was in the pom file.