Sketch works in p3 but not p4

I had a sketch a wrote in processing.py (3 (the non blue logo version)) that ran on my older 2017 mbp
I also have a 2021 mbp (m1) with processing.py (4 (the blue one)) running on it.
For some reason my sketch file only runs on the older processing version (on my older machine)
When I try to run it on the newer machine/software I get tons of errors about

“ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader ‘bootstrap’)
at jycessing.LibraryImporter.addJarToClassLoader(Unknown Source)
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(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._pyx17.f$0(Etheracts1.pyde:1)
at org.python.pycode._pyx17.call_function(Etheracts1.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._pyx16.f$0(/Volumes/TheShed/Etheracts1/Etheracts1.pyde:96)
at org.python.pycode._pyx16.call_function(/Volumes/TheShed/Etheracts1/Etheracts1.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(Unknown Source)
at jycessing.PAppletJythonDriver.findSketchMethods(Unknown Source)
at jycessing.Runner.runSketchBlocking(Unknown Source)
at jycessing.mode.run.SketchRunner.lambda$startSketch$3(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:829)”

Is this a problem with my newer machine? Or with the different versions of the software?

Welcome @degendev

Is it possible to share the sketch code?

Hi @tabreturn

I see this error when I try to load any library with add_library statement.
And looks like it appears in Processing 4 due to the switch to Java 17.
In the stackoverflow there are many questions regarding similar problems after switching to Java 9 and higher
See for example Java 9, compatability issue with ClassLoader.getSystemClassLoader - Stack Overflow

In my Processin 4.0b8 with Python mode 4001 under Windows 10 and with OpenJdk 17.0.2 next script generates such error:
add_library(“sound”)
def setup():
snd = SoundFile(this,“sound.mp3”)

I recommend you use Processing 3.5.4 for Python Mode. At least until Processing 4 is out of beta.

1 Like