Gubaer / josm-scripting-plugin

Task automation in the OpenStreetMap editor JOSM
https://gubaer.github.io/josm-scripting-plugin
GNU General Public License v3.0
26 stars 9 forks source link

java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; #79

Closed JulienPalard closed 1 year ago

JulienPalard commented 5 years ago

I'm getting this exception while trying the Python scripting interface, I'm using Jython 2.7.1 on Debian:

{{{
URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2019-03-31 21:17:00 +0200 (Sun, 31 Mar 2019)
Build-Date:2019-03-31 20:25:18
Revision:14945
Relative:URL: ^/trunk

Identification: JOSM/1.5 (14945 en) Linux Debian GNU/Linux buster/sid
Memory Usage: 496 MB / 1756 MB (273 MB allocated, but free)
Java version: 1.8.0_201-b09, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: :0.0 1920x1080, :0.1 1920x1080
Maximum Screen Size: 1920x1080

Plugins:
+ scripting (30794)
+ utilsplugin2 (34932)

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.
- E: Handled by bug report queue: java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;

=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (17) of main
java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
    at org.python.core.io.BufferedReader.clear(BufferedReader.java:147)
    at org.python.core.io.BufferedReader.<init>(BufferedReader.java:27)
    at org.python.core.PyFile.createBuffer(PyFile.java:227)
    at org.python.core.PyFile.file___init__(PyFile.java:185)
    at org.python.core.PyFile.file___init__(PyFile.java:178)
    at org.python.core.PyFile.<init>(PyFile.java:101)
    at org.python.core.PySystemState.<init>(PySystemState.java:237)
    at org.python.util.PythonInterpreter.threadLocalStateInterpreter(PythonInterpreter.java:81)
    at org.python.jsr223.PyScriptEngine.<init>(PyScriptEngine.java:27)
    at org.python.jsr223.PyScriptEngineFactory.getScriptEngine(PyScriptEngineFactory.java:85)
    at org.openstreetmap.josm.plugins.scripting.model.JSR223ScriptEngineProvider.lambda$getScriptEngine$12(JSR223ScriptEngineProvider.java:307)
    at java.util.Optional.map(Optional.java:215)
    at org.openstreetmap.josm.plugins.scripting.model.JSR223ScriptEngineProvider.getScriptEngine(JSR223ScriptEngineProvider.java:307)
    at org.openstreetmap.josm.plugins.scripting.ui.ScriptExecutor.runScriptWithPluggedEngine(ScriptExecutor.java:255)
    at org.openstreetmap.josm.plugins.scripting.ui.RunScriptService.runScript(RunScriptService.java:180)
    at org.openstreetmap.josm.plugins.scripting.ui.RunScriptService.runScript(RunScriptService.java:147)
    at org.openstreetmap.josm.plugins.scripting.ui.MostRecentlyRunScriptsModel$RunScriptAction.actionPerformed(MostRecentlyRunScriptsModel.java:151)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6539)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6304)
    at java.awt.Container.processEvent(Container.java:2239)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2297)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
    at java.awt.Container.dispatchEventImpl(Container.java:2283)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    at java.awt.EventQueue$4.run(EventQueue.java:733)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
}}}

I just tried to run:

from org.openstreetmap.josm.plugins.scripting.python import JosmPythonPlugin

class HelloWorldPlugin(JosmPythonPlugin):
    def onLoad(self):
        print "onLoad: starting ..."

    def onMapFrameChanged(self, oldFrame, newFrame):
        print "onMapFrameChanged:"
        print "   old frame is: ", oldFrame
        print "   new frame is: ", newFrame
Gubaer commented 5 years ago

Most likely on your system a jython-jar is present, which was compiled with Java 9. Please download the "official" jython jar, i.e. from here, and configure JOSM to use this jar.

Does this solve the problem?

JulienPalard commented 5 years ago

I'm using jython 2.7.1+repack1-2 from http://ftp.fr.debian.org/debian testing/main amd64 Packages is there a way to know against which Java version it was compiled?

Gubaer commented 1 year ago

Python plugins are not supported anymore. Closing this issue.