Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jnius.JavaException: Class not found #106

Closed
nesergen opened this issue Apr 13, 2014 · 4 comments
Closed

jnius.JavaException: Class not found #106

nesergen opened this issue Apr 13, 2014 · 4 comments

Comments

@nesergen
Copy link

Ubuntu 12.04, java oracle jdk 1.8.0, python 2.7, pyjnius latest

Trying to make programm with python, kivy and pyjnius.
After run the program error raised:

@sergen-pc:~$ python /home/sergen/PythonExp/kivy_exp/db_extr_v3/main.py
[INFO   ] Kivy v1.8.1-dev
[INFO   ] [Python      ] v2.7.3 (default, Feb 27 2014, 19:58:35) 
[GCC 4.6.3]
[INFO   ] [Logger      ] Record log in /home/sergen/.kivy/logs/kivy_14-04-14_0.txt
[INFO   ] [Factory     ] 157 symbols loaded
[DEBUG  ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG  ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG  ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_pil, img_gif 
[DEBUG  ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG  ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[INFO   ] [Text        ] Provider: pygame
[DEBUG  ] [Window      ] Ignored <egl_rpi> (import error)
[INFO   ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)
[DEBUG  ] [Window      ] Display driver x11
[DEBUG  ] [Window      ] Actual window size: 800x600
[DEBUG  ] [Window      ] Actual color bits r8 g8 b8 a0
[DEBUG  ] [Window      ] Actual depth bits: 24
[DEBUG  ] [Window      ] Actual stencil bits: 8
[DEBUG  ] [Window      ] Actual multisampling samples: 2
[INFO   ] [GL          ] OpenGL version <3.3.0 NVIDIA 331.20>
[INFO   ] [GL          ] OpenGL vendor <NVIDIA Corporation>
[INFO   ] [GL          ] OpenGL renderer <GeForce 8600 GT/PCIe/SSE2>
[INFO   ] [GL          ] OpenGL parsed version: 3, 3
[INFO   ] [GL          ] Shading version <3.30 NVIDIA via Cg compiler>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <32>
[DEBUG  ] [Shader      ] Fragment compiled successfully
[DEBUG  ] [Shader      ] Vertex compiled successfully
[DEBUG  ] [ImagePygame ] Load </usr/lib/python2.7/dist-packages/kivy/data/glsl/default.png>
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[DEBUG  ] [App         ] Loading kv </home/sergen/PythonExp/kivy_exp/db_extr_v3/my.kv>
[DEBUG  ] [Atlas       ] Load </usr/lib/python2.7/dist-packages/kivy/data/../data/images/defaulttheme.atlas>
[DEBUG  ] [Atlas       ] Need to load 1 images
[DEBUG  ] [Atlas       ] Load </usr/lib/python2.7/dist-packages/kivy/data/../data/images/defaulttheme-0.png>
[DEBUG  ] [ImagePygame ] Load </usr/lib/python2.7/dist-packages/kivy/data/../data/images/defaulttheme-0.png>
[DEBUG  ] [Cache       ] register <kv.loader> with limit=500, timeout=60s
[INFO   ] [Loader      ] using a thread pool of 2 workers
[DEBUG  ] [Cache       ] register <textinput.label> with limit=None, timeout=60.0s
[DEBUG  ] [Cache       ] register <textinput.width> with limit=None, timeout=60.0s
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [OSC         ] using <multiprocessing> for socket
[DEBUG  ] [Base        ] Create provider from mouse
[DEBUG  ] [Base        ] Create provider from probesysfs
[DEBUG  ] [ProbeSysfs  ] using probsysfs!
[INFO   ] [Base        ] Start application main loop
self instance <__main__.Root object at 0x2da3390>
Конец

[DEBUG  ] [Window      ] Display driver x11
[DEBUG  ] [Window      ] Actual window size: 600x800
[DEBUG  ] [Window      ] Actual color bits r8 g8 b8 a0
[DEBUG  ] [Window      ] Actual depth bits: 24
[DEBUG  ] [Window      ] Actual stencil bits: 8
[DEBUG  ] [Window      ] Actual multisampling samples: 2
OK import jnius
[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "/home/sergen/PythonExp/kivy_exp/db_extr_v3/main.py", line 275, in <module>
     MyApp().run()
   File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 800, in run
     runTouchApp()
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 481, in runTouchApp
     EventLoop.window.mainloop()
   File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 381, in mainloop
     self._mainloop()
   File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 287, in _mainloop
     EventLoop.idle()
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 324, in idle
     self.dispatch_input()
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 309, in dispatch_input
     post_dispatch_input(*pop(0))
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 275, in post_dispatch_input
     wid.dispatch('on_touch_up', me)
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4555)
   File "/usr/lib/python2.7/dist-packages/kivy/uix/behaviors.py", line 110, in on_touch_up
     self.dispatch('on_release')
   File "_event.pyx", line 312, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4509)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1397, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "/home/sergen/PythonExp/kivy_exp/db_extr_v3/my.kv", line 22, in <module>
     on_release: root.parent.fast_start()
   File "/home/sergen/PythonExp/kivy_exp/db_extr_v3/main.py", line 52, in fast_start
     self.ConnectDB()
   File "/home/sergen/PythonExp/kivy_exp/db_extr_v3/main.py", line 65, in ConnectDB
     b=jnius.autoclass('org.h2.jdbcx.JdbcConnectionPool')
   File "/usr/local/lib/python2.7/dist-packages/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:12229)
 jnius.JavaException: Class not found 'org/h2/jdbcx/JdbcConnectionPool'

"org/h2/jdbcx/JdbcConnectionPool" is connector for DataBase copied to the "/usr/lib/jvm/jdk1.8.0/jre/lib"

test of pyjnius printing this:

@sergen-pc:~/PythonExp/pyjnius-master$ 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
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -g -I/usr/lib/jvm/jdk1.8.0/include -I/usr/lib/jvm/jdk1.8.0/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:3259:3: warning: passing argument 2 of ‘(*__pyx_v_5jnius_jvm)->AttachCurrentThread’ from incompatible pointer type [enabled by default]
jnius/jnius.c:3259: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:13094:30: warning: assignment from incompatible pointer type [enabled by default]
jnius/jnius.c:13103:30: warning: assignment from incompatible pointer type [enabled by default]
jnius/jnius.c: In function ‘__pyx_f_5jnius_convert_python_to_jobject’:
jnius/jnius.c:9190:21: warning: ‘__pyx_v_retmidinit’ may be used uninitialized in this function [-Wuninitialized]
jnius/jnius.c:9190:21: warning: ‘__pyx_v_retclass’ may be used uninitialized in this function [-Wuninitialized]
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -g build/temp.linux-x86_64-2.7/jnius/jnius.o -L/usr/lib/jvm/jdk1.8.0/jre/lib/amd64/server -ljvm -o /home/sergen/PythonExp/pyjnius-master/jnius/jnius.so -Wl,-rpath /usr/lib/jvm/jdk1.8.0/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 && 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_string_output_args (test_output_args.OutputArgs) ... ok
Failure: Exception (Invalid "]" character in definition "Landroid/bluetooth/BluetoothDevice;IB[])V") ... ERROR
test_stack (test_reflect.ReflectTest) ... ok
test_helloworld (test_simple.HelloWorldTest) ... ok

======================================================================
ERROR: Failure: Exception (Invalid "]" character in definition "Landroid/bluetooth/BluetoothDevice;IB[])V")
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/sergen/PythonExp/pyjnius-master/tests/test_proxy.py", line 153, in <module>
    TestBadSignature()
  File "jnius_proxy.pxi", line 42, in jnius.PythonJavaClass.__init__ (jnius/jnius.c:22764)
  File "jnius_utils.pxi", line 32, in jnius.parse_definition (jnius/jnius.c:3705)
Exception: Invalid "]" character in definition "Landroid/bluetooth/BluetoothDevice;IB[])V"

----------------------------------------------------------------------
Ran 41 tests in 0.425s

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

If I write in python this...

>>> from jnius import autoclass
>>> autoclass('java.lang.System').out.println('Hello world')

...all is OK.

when I worked with OpenJava everything worked normally, with JavaSun it doesn't work.

@nesergen
Copy link
Author

nesergen commented May 7, 2014

solved. added folder with .jar to the CLASSPATH

@nesergen nesergen closed this as completed May 7, 2014
@dessant dessant changed the title jnius.JavaException: Class not found jnius.JavaException: Class not found Jan 15, 2015
@kakkarotssj
Copy link

@nesergen . Can you please explain in detail what you did to solve this problem, it looks like I having the similar problem now.
Thanks

@nesergen
Copy link
Author

nesergen commented Mar 1, 2017

@kakkarotssj . I think I did this : export CLASSPATH=/usr/local/java/tools.jar:$CLASSPATH
where /usr/local/java/tools.jar the path to your jar file

@chetankoona
Copy link

add
from jnius import JavaException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants