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

java.lang.NoClassDefFoundError with bRigid library #300

Open co-ord opened 4 years ago

co-ord commented 4 years ago

Hi,

I have the following error when trying to import the bRigid library in Python mode:

sketch_200701c.pyde:1: RuntimeWarning: PyTableCode.call caught a Throwable that is not an Exception:
java.lang.NoClassDefFoundError: LBPhysics;
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('bRigid')
processing.app.SketchException: java.lang.NoClassDefFoundError: LBPhysics;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.python.core.PyJavaType.init(PyJavaType.java:421)
    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._pyx264.f$0(<string>:1)
    at org.python.pycode._pyx264.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(Unknown Source)
    at jycessing.LibraryImporter.addLibrary(Unknown Source)
    at jycessing.LibraryImporter$1.__call__(Unknown Source)
    at org.python.core.PyObject.__call__(PyObject.java:480)
    at org.python.core.PyObject.__call__(PyObject.java:484)
    at org.python.pycode._pyx237.f$0(sketch_200701c.pyde:1)
    at org.python.pycode._pyx237.call_function(sketch_200701c.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.setup(Unknown Source)
    at processing.core.PApplet.handleDraw(PApplet.java:2432)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.lang.ClassNotFoundException: BPhysics
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 47 more

    at jycessing.mode.run.SketchRunner.convertPythonSketchError(Unknown Source)
    at jycessing.mode.run.SketchRunner.lambda$startSketch$3(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)

I have seen your reply to a similar issue but the difference here is that:

1/ there are no further directories in libraries/bRigid/library 2/ even if there were extra directories, the latest version of Python mode should normally have handled the import

Path:

Processing/libraries/bRigid/library : -- bRigid.jar -- jbullet.jar -- vecmath.jar

co-ord commented 4 years ago

Hi @jdf,

Would you mind to just tell me if you think there is a fix around this issue. I am currently working an important project and depending on your answer I can decide if I keep using Processing or move on to another environment.

Thank you

mpsftw commented 4 years ago

Does this work in java mode?

Java is looking for LBPhysics, which isn't in the bRigid/library directory. It looks like it's in the src/bRigid/ directory. If you copied it into the bRidid/library directory you probably wouldn't get this error.

co-ord commented 4 years ago

Hi @mpsftw,

Thank you for your message.

The library does work in Java mode. I have already tried to place the BPhysics java file into the library folder but unfortunately this didn't work either. For some reason I also have to load the PeasyCam library first or I get the same kind of error:

sketch_200705d.pyde:1: RuntimeWarning: PyTableCode.call caught a Throwable that is not an Exception:
java.lang.NoClassDefFoundError: Lpeasy/PeasyCam;

All this is a mystery to me.

mpsftw commented 4 years ago

Can you post an example?

co-ord commented 4 years ago

Sure !

It will be a very minimalist example since the error shows up when importing the library.

add_library('bRigid')

returns:

sketch_200705e.pyde:1: RuntimeWarning: PyTableCode.call caught a Throwable that is not an Exception:
java.lang.NoClassDefFoundError: Lpeasy/PeasyCam;
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('bRigid')
processing.app.SketchException: java.lang.NoClassDefFoundError: Lpeasy/PeasyCam;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.python.core.PyJavaType.init(PyJavaType.java:421)
    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._pyx37.f$0(<string>:1)
    at org.python.pycode._pyx37.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(Unknown Source)
    at jycessing.LibraryImporter.addLibrary(Unknown Source)
    at jycessing.LibraryImporter$1.__call__(Unknown Source)
    at org.python.core.PyObject.__call__(PyObject.java:480)
    at org.python.core.PyObject.__call__(PyObject.java:484)
    at org.python.pycode._pyx10.f$0(sketch_200705e.pyde:1)
    at org.python.pycode._pyx10.call_function(sketch_200705e.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.setup(Unknown Source)
    at processing.core.PApplet.handleDraw(PApplet.java:2432)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.lang.ClassNotFoundException: peasy.PeasyCam
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 47 more

    at jycessing.mode.run.SketchRunner.convertPythonSketchError(Unknown Source)
    at jycessing.mode.run.SketchRunner.lambda$startSketch$3(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)

And when importing PeasyCam first,

add_library('peasycam')
add_library('bRigid')

returns:


sketch_200705e.pyde:1: RuntimeWarning: PyTableCode.call caught a Throwable that is not an Exception:
java.lang.NoClassDefFoundError: LBPhysics;
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('bRigid')
processing.app.SketchException: java.lang.NoClassDefFoundError: LBPhysics;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.python.core.PyJavaType.init(PyJavaType.java:421)
    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._pyx76.f$0(<string>:1)
    at org.python.pycode._pyx76.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(Unknown Source)
    at jycessing.LibraryImporter.addLibrary(Unknown Source)
    at jycessing.LibraryImporter$1.__call__(Unknown Source)
    at org.python.core.PyObject.__call__(PyObject.java:480)
    at org.python.core.PyObject.__call__(PyObject.java:484)
    at org.python.pycode._pyx42.f$0(sketch_200705e.pyde:2)
    at org.python.pycode._pyx42.call_function(sketch_200705e.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.setup(Unknown Source)
    at processing.core.PApplet.handleDraw(PApplet.java:2432)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.lang.ClassNotFoundException: BPhysics
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 47 more

    at jycessing.mode.run.SketchRunner.convertPythonSketchError(Unknown Source)
    at jycessing.mode.run.SketchRunner.lambda$startSketch$3(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)
mpsftw commented 4 years ago

The problem seems to be coming from some test classes included in the bRigid.jar file:

LibraryImporter: from bRigid import BBox
LibraryImporter: from bRigid import BCompound
LibraryImporter: from bRigid import BConvexHull
LibraryImporter: from bRigid import BForce
LibraryImporter: from bRigid import BForceAttraction
LibraryImporter: from bRigid import BForceAttractionLocal
LibraryImporter: from bRigid import BForceLocalSwarm
LibraryImporter: from bRigid import BGImpactMesh
LibraryImporter: from bRigid import BGImpactMeshPart
LibraryImporter: from bRigid import BInterface
LibraryImporter: from bRigid import BJoint6DofC
LibraryImporter: from bRigid import BJointHinge
LibraryImporter: from bRigid import BJointNail
LibraryImporter: from bRigid import BJointPoint
LibraryImporter: from bRigid import BJointSlider
LibraryImporter: Rejecting bRigid/BObject$1.class
LibraryImporter: Rejecting bRigid/BObject$GlDrawcallback.class
LibraryImporter: from bRigid import BObject
LibraryImporter: from bRigid import BPhysics
LibraryImporter: from bRigid import BPlane
LibraryImporter: from bRigid import BSphere
LibraryImporter: from bRigid import BSpring6DofC
LibraryImporter: from bRigid import BSpringHinge
LibraryImporter: from bRigid import BSpringNail
LibraryImporter: from bRigid import BSpringSlider
LibraryImporter: from bRigid import BTerrain
LibraryImporter: from bRigid.test import Rigid01

SketchRunner: Sketch runner caught java.lang.ClassNotFoundException: BPhysics
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

I suspect the test classes are importing libraries that need to be imported explicitly in jython, but I have no idea what those are as the test source isn't included.

If there is a fixable problem with the way python mode imports libraries (which there may be), I'm not going to be able to find it with what I have. Someone else might chime in here, but at this point I don't know what can be done to make this library work with python mode.

jeremydouglass commented 4 years ago

See also workaround on forum: https://discourse.processing.org/t/brigid-import-workaround-for-python-mode/22402

co-ord commented 4 years ago

Also, following the investigations of @mpsftw (many thanks for your time) I tried to convert all the java files in src to jar format with Eclipse and then place them in the library folder but the same error message appears. I am sticking to GoToLoop helpful workaround for now hoping that we will find what is causing this importation problem.