question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE while invoking tinylog from an AIDL remote interface callback

See original GitHub issue

My code is throwing an exception for this constructor:

	public ServiceLoader(final Class<? extends T> service, final Class<?>... argumentTypes) {
		this.service = service;
		this.argumentTypes = argumentTypes;
		this.classLoader = Thread.currentThread().getContextClassLoader();
		this.classes = loadClasses(classLoader, service);
	}
01-13 12:08:03.272 3989-4000/loylap.poynt.gift E/JavaBinder: *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
    java.lang.ExceptionInInitializerError
        at org.tinylog.provider.ProviderRegistry.getLoggingProvider(ProviderRegistry.java:53)
        at org.tinylog.kotlin.Logger.<clinit>(Logger.kt:27)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Enumeration java.lang.ClassLoader.getResources(java.lang.String)' on a null object reference
        at org.tinylog.configuration.ServiceLoader.loadClasses(ServiceLoader.java:128)
        at org.tinylog.configuration.ServiceLoader.<init>(ServiceLoader.java:58)
        at org.tinylog.provider.ProviderRegistry.loadLoggingProvider(ProviderRegistry.java:66)
        at org.tinylog.provider.ProviderRegistry.<clinit>(ProviderRegistry.java:36)
        at org.tinylog.provider.ProviderRegistry.getLoggingProvider(ProviderRegistry.java:53) 
        at org.tinylog.kotlin.Logger.<clinit>(Logger.kt:27) 

I believe Thread.currentThread().getContextClassLoader(); is returning null in certain instances in my app. I don’t understand enough about Java or AIDLs to see what’s happening here, but suffice it to say calls to log functions (such as Logger.trace()) are crashing when they are invoked from very specific interface call backs in my app which use AIDL and are on a background thread. Running Logger.trace on the main thread from within the interface callback fixes the issue, but I am worried now there could be places in my code I don’t make this fix, and also that I might be introducing other subtle issues I don’t know about, like this one.

This is probably an Android only problem, but would love to know what the cause is and how I might mitigate it. It’s super difficult for me to try and make a reproducible sample because I am seeing the error in an SDK dependency which uses TinyLog

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
danielwilson1702commented, Jan 16, 2020

I’ve tried it with a super simple AIDL / Service sample and can’t repro. So it must be something relatively specific. I will try and create a very simple project with nothing but the Service I am using. Versions are:

  api 'org.tinylog:tinylog-api-kotlin:2.0.1'
  api 'org.tinylog:tinylog-impl:2.0.1'
0reactions
github-actions[bot]commented, Oct 9, 2022

This closed issue has been locked automatically. However, please feel free to file a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NPE while invoking tinylog from an AIDL remote interface ...
My code is throwing an exception for this constructor: public ServiceLoader(final Class service, final Class.
Read more >
Nullpointer exception when calling remote service method
//This where i am calling service method in my activity initService(); service.add ; //this call causing null pointer exception ///My .aidl file ...
Read more >
Passing Callback to an Activity in a library - AndroidBugFix
A library that I am using has an Android activity. I would like to pass a callback to the activity to get notified...
Read more >
[FIXED] java.lang.NullPointerException - JavaFixing
I always get an Error in my Android Project. java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found