Yes, i guess it returns a null pointer exception if the path does not start with '/var/dam'.
Could you try below
Asset footerLn1 = manager.getAssetForBinary("/var/dam/mysite/texts/footer-line1.txt" );
As I mentioned in my post, I have tried 'var/dam/...' as well, still getting NullPointerException. Also, just to clarify, tried both '/var/dam/...' and 'var/dam/...'.
Your piece of code is valid on CQ 5.4/5.5/5.6 and should return the Asset.
Then the content of your text file can be retrieved with
Resource original = asset.getOriginal();
InputStream stream = original.adaptTo(InputStream.class);
The N.P.E. could be thrown because manager is null , or the asset is not retrieved .
One reason could be the logged in user doesn't have access right to the underlying asset, can you verify the ACL set on DAM ?
If this still doesn't help, I would recommend to file a ticket in the Daycare Support Portal (1), where you'd provide your exact test case plus logs.
NullPointerException in line 2 would mean that your AssetManager reference is coming out null.
Try putting some conditional loggers to verify this.
Also you could check if all your bundles are up and in active state.
If you are writing your code in a JSP wouldn't AssetManager be available as an implicit object? (Sorry, don't have access to my work system right now).
If these don't work then post the exception stack trace.
I have logged a call with Adobe Daycare.
Have not explicitely set ACL on this asset, so I suppose it's allowed?
The AssetManager is not null. I printed a simple log which prints out the class name of the AssetManager object:
is manager null? class com.day.cq.dam.core.impl.AssetManagerImpl
Still not working.
But using node.getNode with the same path worked. So the problem is kinda resolved but not ideal as I'd like to use AssetManager to retrieve asset nodes..
Thanks guys for all your replies! really appreciated.