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

Xena_bcn
Xena_bcnAuthor
Level 5
Oct 16, 2015 2:28 AM UTC

thank you I will try it now.

Translate
Xena_bcn
Xena_bcnAuthor
Level 5
Oct 16, 2015 2:28 AM UTC

Hello @edubey

Thank you a lot

it worked !

I didn't reply till now because I got engaged with another task before I tried your solution just now.

Translate
Xena_bcn
Xena_bcnAuthor
Level 5
Oct 16, 2015 2:28 AM UTC

I did as u said. it is not printing anything from the private method

 

anyway i can move all the commands to the public method it was called. without using a function

Translate
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();
Translate
Xena_bcn
Xena_bcnAuthor
Level 5
Oct 16, 2015 2:28 AM UTC

HI

Today it is working...

I can see an error:

HEAD /content/dam/project/path/filename.pdf HTTP/1.1] org.apache.sling.auth.core.impl.SlingAuthenticator getAnonymousResolver: Anonymous access not allowed by configuration - requesting credentials

How can  I get DAM file size ?

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

Did it worked?

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

Methods, Variables and Constructors that are declared private can only be accessed within the declared class itself.

So as long as its in same class it should not be a problem.

Do one things , flood your getDownloadText() method with logger so that you can see where its getting break.

Translate
Xena_bcn
Xena_bcnAuthor
Level 5
Oct 16, 2015 2:28 AM UTC

yes exactly dear Edubey

but only that new line before calling the private method getFileSize

 

is it because it is private?

Translate
Xena_bcn
Xena_bcnAuthor
Level 5
Oct 16, 2015 2:28 AM UTC

It didn't print after URL url =  new URL (filepath);

 

filepath was a path to DAM like /content/project/path/filename.pdf

 

then I added localhost:4502 to it

but now it is  not printing anything....

 

so i stopped and doing another task.

 

seems bad luck, hahaha

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

are you able to see logs which u added?

Translate