jdf / Processing.py-Bugs

A home for all bugs and feature requests about Python Mode for the Processing Development Environment.
41 stars 8 forks source link

LibraryImporter needs to search library/ subdirectories #225

Closed liavkoren closed 6 years ago

liavkoren commented 6 years ago

Can't even import it:

add_library('toxiclibs')

def setup():
    size(500, 500, P3D)
    print(globals())

Raises:

sketch_180413b.pyde:1: RuntimeWarning: PyTableCode.call caught a Throwable that is not an Exception:
java.lang.NoClassDefFoundError: net/java/games/joal/AL
Jython internals might be in a bad state now that can cause deadlocks later on.
See http://bugs.jython.org/issue2536 for details.
  add_library('toxiclibs')
processing.app.SketchException: java.lang.ClassNotFoundException: net.java.games.joal.AL
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getConstructors(Class.java:1651)
    at org.python.core.PyJavaType.init(PyJavaType.java:529)
    at org.python.core.PyType.createType(PyType.java:1523)
    at org.python.core.PyType.addFromClass(PyType.java:1462)
    at org.python.core.PyType.fromClass(PyType.java:1551)
    at org.python.core.adapter.ClassicPyObjectAdapter$6.adapt(ClassicPyObjectAdapter.java:77)
    at org.python.core.adapter.ExtensiblePyObjectAdapter.adapt(ExtensiblePyObjectAdapter.java:44)
    at org.python.core.adapter.ClassicPyObjectAdapter.adapt(ClassicPyObjectAdapter.java:131)
    at org.python.core.Py.java2py(Py.java:2017)
    at org.python.core.PyJavaPackage.addClass(PyJavaPackage.java:86)
    at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:135)
    at org.python.core.PyObject.__findattr__(PyObject.java:965)
    at org.python.core.PyObject.__findattr__(PyObject.java:950)
    at org.python.core.imp.ensureFromList(imp.java:1016)
    at org.python.core.imp.ensureFromList(imp.java:990)
    at org.python.core.imp.import_module_level(imp.java:977)
    at org.python.core.imp.importName(imp.java:1057)
    at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
    at org.python.core.PyObject.__call__(PyObject.java:450)
    at org.python.core.__builtin__.__import__(__builtin__.java:1232)
    at org.python.core.imp.importFromAs(imp.java:1149)
    at org.python.core.imp.importFrom(imp.java:1124)
    at org.python.pycode._pyx12.f$0(<string>:1)
    at org.python.pycode._pyx12.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java:171)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.Py.runCode(Py.java:1614)
    at org.python.core.Py.exec(Py.java:1658)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:267)
    at jycessing.LibraryImporter.importPublicClassesFromJar(LibraryImporter.java:427)
    at jycessing.LibraryImporter.addLibrary(LibraryImporter.java:159)
    at jycessing.LibraryImporter$1.__call__(LibraryImporter.java:85)
    at org.python.core.PyObject.__call__(PyObject.java:480)
    at org.python.core.PyObject.__call__(PyObject.java:484)
    at org.python.pycode._pyx11.f$0(sketch_180413b.pyde:1)
    at org.python.pycode._pyx11.call_function(sketch_180413b.pyde)
    at org.python.core.PyTableCode.call(PyTableCode.java:171)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.Py.runCode(Py.java:1614)
    at org.python.core.Py.exec(Py.java:1658)
    at org.python.pycode._pyx10.f$0(/var/folders/4x/9g74c86d7k1bzcqy50r_xdcc0000gn/T/sketch_180413b2488347758713729458/sketch_180413b.pyde:96)
    at org.python.pycode._pyx10.call_function(/var/folders/4x/9g74c86d7k1bzcqy50r_xdcc0000gn/T/sketch_180413b2488347758713729458/sketch_180413b.pyde)
    at org.python.core.PyTableCode.call(PyTableCode.java:171)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.Py.runCode(Py.java:1614)
    at org.python.core.Py.exec(Py.java:1658)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
    at jycessing.PAppletJythonDriver.processSketch(PAppletJythonDriver.java:230)
    at jycessing.PAppletJythonDriver.findSketchMethods(PAppletJythonDriver.java:585)
    at jycessing.Runner.runSketchBlocking(Runner.java:387)
    at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:118)
    at java.lang.Thread.run(Thread.java:748)

    at jycessing.mode.run.SketchRunner.convertPythonSketchError(SketchRunner.java:234)
    at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:125)
    at java.lang.Thread.run(Thread.java:748)
jdf commented 6 years ago

Inside libraries/toxiclibs/library are further directories containing jars and native libs. Those need to be added to the classpath and native search path before importing classes from the main jar.

jdf commented 6 years ago

Deployed at version 3037.

jdf commented 6 years ago

And thank you for the very helpful report!

liavkoren commented 6 years ago

Amazing. Thank you. I was kind of interested in having to write my own AABB tree implementation, but that wasn't really the problem I want to be solving right now.. : )