pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Class not found 'org/jnius/NativeInvocationHandler'

Open AdamAtri opened this issue 10 years ago • 6 comments

Tried to run "make tests":

adam@GPDevMachine:~/Downloads/tmp/pyjnius$ make tests javac jnius/src/org/jnius/NativeInvocationHandler.java python setup.py build_ext --inplace -f -g /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) running build_ext cythoning jnius/jnius.pyx to jnius/jnius.c warning: jnius/jnius.pyx:2:0: getslice, setslice, and delslice are not supported by Python 3, use getitem, setitem, and delitem instead building 'jnius' extension x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -g -I/usr/lib/jvm/java-7-openjdk-amd64/include -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux -I/usr/include/python2.7 -c jnius/jnius.c -o build/temp.linux-x86_64-2.7/jnius/jnius.o jnius/jnius.c: In function ‘__pyx_f_5jnius_get_jnienv’: jnius/jnius.c:2933:3: warning: passing argument 2 of ‘(_pyx_v_5jnius_jvm)->AttachCurrentThread’ from incompatible pointer type enabled by default->AttachCurrentThread(__pyx_v_5jnius_jvm, (&__pyx_v_env), NULL); ^ jnius/jnius.c:2933:3: note: expected ‘void *’ but argument is of type ‘const struct JNINativeInterface ***’ jnius/jnius.c: In function ‘__pyx_pf_5jnius_13MetaJavaClass_4resolve_class’: jnius/jnius.c:13091:30: warning: assignment from incompatible pointer type enabled by default = ((jobject *)__pyx_v_classLoader); ^ jnius/jnius.c:13100:30: warning: assignment from incompatible pointer type enabled by default = __pyx_v_interfaces; ^ x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -g build/temp.linux-x86_64-2.7/jnius/jnius.o -L/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server -ljvm -o /home/adam/Downloads/tmp/pyjnius/jnius/jnius.so -Wl,-rpath /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server cd tests && javac org/jnius/HelloWorld.java cd tests && javac org/jnius/BasicsTest.java cd tests && javac org/jnius/MultipleMethods.java cd tests && javac org/jnius/SimpleEnum.java cd tests && javac org/jnius/InterfaceWithPublicEnum.java cd tests && javac org/jnius/ClassArgument.java cd tests && javac org/jnius/MultipleDimensions.java cd tests && env PYTHONPATH=..: nosetests-2.7 -v test_assignable (test_assignable.AssignableFrom) ... ok test_class_not_found (test_bad_declaration.BadDeclarationTest) ... ok test_invalid_attribute (test_bad_declaration.BadDeclarationTest) ... ok test_invalid_static_call (test_bad_declaration.BadDeclarationTest) ... ok test_with_too_much_arguments (test_bad_declaration.BadDeclarationTest) ... ok test_instance_fields (test_basics.BasicsTest) ... ok test_instance_methods (test_basics.BasicsTest) ... ok test_instances_methods_array (test_basics.BasicsTest) ... ok test_instances_methods_params (test_basics.BasicsTest) ... ok test_instances_methods_params_array_byte (test_basics.BasicsTest) ... ok test_instances_methods_params_object_list_float (test_basics.BasicsTest) ... ok test_instances_methods_params_object_list_int (test_basics.BasicsTest) ... ok test_instances_methods_params_object_list_long (test_basics.BasicsTest) ... ok test_instances_methods_params_object_list_str (test_basics.BasicsTest) ... ok test_return_array_as_object_array_of_strings (test_basics.BasicsTest) ... ok test_return_array_as_object_of_integers (test_basics.BasicsTest) ... ok test_static_fields (test_basics.BasicsTest) ... ok test_static_methods (test_basics.BasicsTest) ... ok test_string_arg_for_byte_array (test_bytearray.StringArgumentForByteArrayTest) ... ok test_multiple_constructors (test_cast.MultipleSignatureTest) ... ok test_static_methods (test_class_argument.BasicsTest) ... ok test_enum (test_enum.SimpleEnum) ... ok test_value (test_enum.SimpleEnum) ... ok test_printf (test_implementation.ImplementationTest) ... hi hi jnius other string ok test_println (test_implementation.ImplementationTest) ... ok test_unicode (test_implementation.ImplementationTest) ... éok test_reflect_enum_in_interface (test_interface.Interface) ... ok test_reflect_interface (test_interface.Interface) ... ok test_multiple_constructors (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_no_args (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_one_arg (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_two_args (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_two_args_and_varargs (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_two_string_and_an_integer (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_two_string_and_two_integers (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_methods_varargs (test_method_multiple_signatures.MultipleSignature) ... ok test_multiple_dimensions (test_multidimension.MultipleDimensionsTest) ... ok test_string_output_args (test_output_args.OutputArgs) ... ok Failure: JavaException (Class not found 'org/jnius/NativeInvocationHandler') ... ERROR test_stack (test_reflect.ReflectTest) ... Exception in thread "main" java.lang.NoClassDefFoundError: org/jnius/NativeInvocationHandler Caused by: java.lang.ClassNotFoundException: org.jnius.NativeInvocationHandler at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ERROR test_helloworld (test_simple.HelloWorldTest) ... ok

ERROR: Failure: JavaException (Class not found 'org/jnius/NativeInvocationHandler')

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 414, in loadTestsFromName addr.filename, addr.module) File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname) File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "/home/adam/Downloads/tmp/pyjnius/tests/test_proxy.py", line 108, in a = TestImplem(_range(10)) File "/home/adam/Downloads/tmp/pyjnius/tests/test_proxy.py", line 57, in init super(TestImplem, self).init(_args) File "jnius_proxy.pxi", line 31, in jnius.PythonJavaClass.init (jnius/jnius.c:22254) File "jnius_proxy.pxi", line 160, in jnius.create_proxy_instance (jnius/jnius.c:24187) File "/home/adam/Downloads/tmp/pyjnius/jnius/reflect.py", line 150, in autoclass c = find_javaclass(clsname) File "jnius_export_func.pxi", line 23, in jnius.find_javaclass (jnius/jnius.c:12269) JavaException: Class not found 'org/jnius/NativeInvocationHandler'

ERROR: test_stack (test_reflect.ReflectTest)

Traceback (most recent call last): File "/home/adam/Downloads/tmp/pyjnius/tests/test_reflect.py", line 8, in test_stack stack = Stack() File "jnius_export_class.pxi", line 147, in jnius.JavaClass.init (jnius/jnius.c:13699) File "jnius_export_class.pxi", line 225, in jnius.JavaClass.call_constructor (jnius/jnius.c:14813) File "jnius_utils.pxi", line 43, in jnius.check_exception (jnius/jnius.c:3506) JavaException: JVM exception occured


Ran 42 tests in 0.097s

FAILED (errors=2) make: *** [tests] Error 1

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6892068-class-not-found-org-jnius-nativeinvocationhandler?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).

AdamAtri avatar Dec 09 '14 22:12 AdamAtri

The issue seems to be caused by commit 2910e2fddcd4f4c4669c14d0bbd81e7b213462bb, which added the jnius_config module to manage java class paths. Previously, os.path.realpath('.') had been added to the class path in jnius_jvm_desktop.pxi, which ensured that org/jnius/NativeInvocationHandler was available, but now there are no entries added to the class path by default, so the class is no longer available. This could be resolved by inserting the path in jnius_config.get_classpath after the path is constructed from the environment or the configured list.

jessecrossen avatar Dec 10 '14 16:12 jessecrossen

It's a bit more involved than my previous comment suggests. The NativeInvocationHandler class file is not being included in the installation package and in addition, no attempt is being made to add its location to the java class path. I've fixed this in a fork of the physion fork, see commit 26f1367ab143cd72203f0db77556279eac8c304f for details. This fix should be easy enough to port to the kivy branch if anyone is interested in doing that.

jessecrossen avatar Dec 10 '14 18:12 jessecrossen

I am also having this issue... +1 for merging this patch.

clintharris avatar Mar 12 '15 22:03 clintharris

I'm having this issue too with a fresh build. +1 for merging.

rbrewer123 avatar Apr 10 '15 13:04 rbrewer123

Any reason why this is still not merged?

AndreMiras avatar Sep 20 '16 21:09 AndreMiras

FWIW, maybe my issue was a little bit different. But I eventually got it working (without the patch) by calling autoclass('org.jnius.NativeInvocationHandler') once in the main thread.

AndreMiras avatar Sep 21 '16 16:09 AndreMiras