Skip to main content
Xena_bcn
Level 5
Oct 16, 2015 2:28 AM UTC
Solved

how to debug or log info in bean

hello here.

So one of my component java bean functions is not returning result I am expecting.

I added log.info  to trace , doesn't print anything.

 

Then used debug from Eclipse , doesn't stop on breakpoints.

 

Where and what I should do?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
edubey
edubeyAccepted solution
Level 10
Oct 16, 2015 2:28 AM UTC

Try this snippet of code.

Resource r = resourceResolver.getResource(path); Asset a = r.adaptTo(Asset.class); Rendition rnd = a.getOriginal(); long size = rnd.getSize();

34 replies

edubey
Level 10
Oct 16, 2015 2:28 AM UTC

I am assuming this is component in OSGI.

I prefer using this library for logging, its very helpful, can you try to integrate this. Its simple

http://www.slf4j.org/manual.html

Translate
Adobe Employee
Oct 16, 2015 2:28 AM UTC

Hi,

for debugging, did you use the approach defined here: https://helpx.adobe.com/experience-manager/kb/CQ5HowToSetupRemoteDebuggingWithEclipse.html

When creating the debugging configuration, did you define where the source code is located?

Regards,

Opkar

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:28 AM UTC

You can log information in the AEM log using code like:

/** Default log. */
protected final Logger log = LoggerFactory.getLogger(this.getClass());
               

private Session session;
private java.util.Iterator<Authorizable> users = null ;
     
//Inject a Sling ResourceResolverFactory
@Reference
private ResourceResolverFactory resolverFactory;
 
@Override
public String getCQUsers() {
         
 try
 {
  //Invoke the adaptTo method to create a Session 
  ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
  session = resourceResolver.adaptTo(Session.class);
             
  //Create a UserManager instance from the session object
  UserManager userManager = ((JackrabbitSession) session).getUserManager();
 
   users= userManager.findAuthorizables("jcr:primaryType", "rep:User");
 
  while (users.hasNext()) {
   
      Authorizable auth = users.next();
      if (!auth.isGroup()) {
 
          //Get the ID of the user
        String id = auth.getID();
        log.info("Retrieved USER "+id) ;
       
    }
        }
     
    // Log out
    session.logout();             
    return "All AEM Users are written to the log file" ;  
}
catch(Exception e)
{
         log.info("CQ ERROR: "+e.getMessage())  ; 
}
         
return null;
 }
}

 

See https://helpx.adobe.com/experience-manager/using/developing-aem-osgi-bundles-jackrabbit.html

Translate
edubey
Level 10
Oct 16, 2015 2:28 AM UTC
Hi, Can you tell me how u r executing this piece of code, are you calling this via some method in your jsp?       
Translate