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

Tests don't pass (doesn't find libraries) #43

Closed
mih opened this issue Nov 6, 2012 · 8 comments
Closed

Tests don't pass (doesn't find libraries) #43

mih opened this issue Nov 6, 2012 · 8 comments

Comments

@mih
Copy link

mih commented Nov 6, 2012

Hi,

I'm trying to run pyjnius on Debian wheezy. The vast majority of the tests (make tests) fails. It seems to be (mostly) related to the fact that it doesn't find the jars required for the tests. The failure looks like this:

======================================================================
ERROR: test_instance_methods (test_basics.BasicsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/michael/hacking/testkraut/db/pyjnius/tests/test_basics.py", line 31, inn test_instance_methods
    test = autoclass('org.jnius.BasicsTest')()
  File "/home/michael/hacking/testkraut/db/pyjnius/jnius/reflect.py", line 109, in autoclass
    c = find_javaclass(clsname)
  File "jnius_export_func.pxi", line 23, in jnius.find_javaclass (jnius/jnius.c:7418)
JavaException: Class not found 'org/jnius/BasicsTest'

I can work with the standard library without problems:

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

but accessing any other JAR fails.

I tried Debian's openjdk 6 and 7 -- the result is the same. It there any (versioned) dependency that I am missing?

@pubfox
Copy link

pubfox commented Jan 1, 2013

same with u

@tito
Copy link
Member

tito commented Jul 2, 2013

Did you compile pyjnius correctly? Did you got errors when compiling the java part?
Without the log, i don't know at all :/

@paulocheque
Copy link

  • Where do we need to put the jar file?
  • Do we need to add some extra parameter in the command line to make pyjnius find the jar file?

The README file just contains examples using the standard Java library.

I have tried to set the CLASSPATH environment variable without success too, check it out my attempts:

ls print my_lib.jar

export CLASSPATH="."
os.environ['CLASSPATH'] = '.'
os.environ['CLASSPATH'] = 'absolute path of jar file'

python my_program.py
>>> jnius.JavaException: Class not found

Related:
4ff916d
#44

@PAStheLoD
Copy link

Hello!

Same problem here. After doing some strace it looks like it's completely ignoring the CLASSPATH.

...
[pid 16635] lstat("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 16635] lstat("/home/pas", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 16635] lstat("/home/pas/projects", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
[pid 16635] lstat("/home/pas/projects/jnius-test", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 16635] stat("/home/pas/projects/jnius-test/org/fusesource/jansi/Ansi.class", 0x7fff0d418090) = -1 ENOENT (No such file or directory)
(test)pas@stranger:~/projects/jnius-test$ ipython 
Python 2.7.5+ (default, Jun  5 2013, 10:40:07) 
Type "copyright", "credits" or "license" for more information.

IPython 1.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import os

In [2]: os.environ['CLASSPATH'] = '/home/pas/projects/typesafe/activator-1.0.10/repository/jline/jline/2.11/jars/jline.jar'

In [3]: import jnius

In [4]: jnius.autoclass('org.fusesource.jansi.Ansi')
---------------------------------------------------------------------------
JavaException                             Traceback (most recent call last)
<ipython-input-4-a42c4e3c774d> in <module>()
----> 1 jnius.autoclass('org.fusesource.jansi.Ansi')

/home/pas/.virtualenvs/test/local/lib/python2.7/site-packages/jnius/reflect.pyc in autoclass(clsname)
    104 
    105     #c = Class.forName(clsname)
--> 106     c = find_javaclass(clsname)
    107     if c is None:
    108         raise Exception('Java class {0} not found'.format(c))

/home/pas/.virtualenvs/test/local/lib/python2.7/site-packages/jnius/jnius.so in jnius.find_javaclass (jnius/jnius.c:7190)()

JavaException: Class not found 'org/fusesource/jansi/Ansi'

I'm mostly writing this comment to resurrect this months old issue. (Also I'll try tinkering with the source to see what's wrong.)

@saguas
Copy link

saguas commented Mar 2, 2014

same with me
Nome da class: java/lang/System
Nome da class: org/saguas/report/MyDbReportFill
Traceback (most recent call last):
File "println.py", line 8, in
MyDbReportFill=autoclass('org.saguas.report.MyDbReportFill')
File "/Library/Python/2.7/site-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:12200)
jnius.JavaException: Class not found 'org/saguas/report/MyDbReportFill'

My classpath is ok. I find my jar file from other java class (with main).

@davidcheng0716
Copy link

I have the same problem and I the "make tests" command didn't run any test case.

$ make tests
javac jnius/src/org/jnius/NativeInvocationHandler.java
...
4 warnings generated.
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. -g build/temp.macosx-10.9-intel-2.7/jnius/jnius.o -o /Users/hotdog16/Downloads/pyjnius-master/jnius/jnius.so -framework JavaVM
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
Ran 0 tests in 0.002s

OK

When I run test by myself:
$ cd tests/
$ PYTHONPATH=..: nosetests test_basics.py
EEEEEEEEEEEEE
ERROR: test_instance_fields (test_basics.BasicsTest)
Traceback (most recent call last):
File "/Users/hotdog16/Downloads/pyjnius-master/tests/test_basics.py", line 43, in test_instance_fields
test = autoclass('org.jnius.BasicsTest')()
File "/Library/Python/2.7/site-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:12356)
JavaException: Class not found 'org/jnius/BasicsTest'
....

@charz
Copy link

charz commented Mar 10, 2014

Hi guys,

I used ubuntu 12.04 and pip install pyjnius (1.0.2) have been seem this problem. when I update the pyjnius to 1.1-dev and the problem was solved.

@dessant
Copy link
Contributor

dessant commented Nov 3, 2015

Fixed in master.

@dessant dessant closed this as completed Nov 3, 2015
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

9 participants