Skip to content

Java Reflection fail on thread #735

Description

@nabil-mansouri

Hi Guys
WHEN USING ANDROID THREAD, SOME CLASSES ARE NOT FOUND BY CLASSLOADER (tns.Runtime.callJS failed).

platform: android
tns-core-modules 2.5.0 version
Runtime version: 2.5.0 version
My Plugin : 1.0.0 version (https://github.com/nabil-mansouri/nativescript-couchbaselite)

I am trying to create a couchbase plugin that make available all features. But when i am trying to create view , i need to emit keys. This is done in couchbase in a separate thread. When my emit bloc is called, it throws a "ClassnotfoundException" on tns runtime. But when i try to get java.lang.Class.forName("com.couchbase.lite.store.SQLiteViewStore$AbstractMapEmitBlock") on main thread , it works! It seems that runtime is not looking on the same classloader?

Here are my unit tests (npm run test-android):
https://github.com/nabil-mansouri/nativescript-couchbaselite/blob/master/tests/app/tests/couchbase.ts
"should live query" failed

On adb logcat i have this stacktrace:

03-24 07:19:19.067 2366 2441 V View : Re-indexing view: users_live
03-24 07:19:19.069 2366 2441 V View : users_live last indexed at #0
03-24 07:19:19.069 2366 2441 V View : Updating indexes of (users_live) from #0 to #4 ...
03-24 07:19:19.164 2366 2441 V View : #1: map '1' for view users_live...
03-24 07:19:19.166 2366 2440 W System.err: java.lang.ClassNotFoundException: com.couchbase.lite.store.SQLiteViewStore$AbstractMapEmitBlock
03-24 07:19:19.185 2366 2440 W System.err: at java.lang.Class.classForName(Native Method)
03-24 07:19:19.185 2366 2440 W System.err: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-24 07:19:19.185 2366 2440 W System.err: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-24 07:19:19.185 2366 2440 W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
03-24 07:19:19.185 2366 2440 W System.err: at com.tns.Runtime.getTypeMetadata(Runtime.java:719)
03-24 07:19:19.185 2366 2440 W System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
03-24 07:19:19.185 2366 2440 W System.err: at com.tns.Runtime.access$2400(Runtime.java:33)
03-24 07:19:19.185 2366 2440 W System.err: at com.tns.Runtime$3.run(Runtime.java:1214)
03-24 07:19:19.185 2366 2440 W System.err: at android.os.Handler.handleCallback(Handler.java:739)
03-24 07:19:19.185 2366 2440 W System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
03-24 07:19:19.185 2366 2440 W System.err: at android.os.Looper.loop(Looper.java:148)
03-24 07:19:19.185 2366 2440 W System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
03-24 07:19:19.185 2366 2440 W System.err: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Edit: proper formatting to help readability

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions