Topics

Having a problem with the Jython Interface..

wombat_rrnut
 

I started developing a simple Jython program for a friend under JMRI.  I am running recent code set

4.17.4ish……. (Did a “sync” about a week ago with master).

 

Problem: calling “addpropertychangelistener” bombs.

Now, just like “AutoDispatcher2.py”, I have at least 50 of these calls to “addpropertychangelistener” that I’ve used

for the last 10+ years, but haven’t yet run with 4.17.4ish (nor can I easily test it).

 

So to eliminate the chance that I’m screwing up, I copied the code directly from the

supplied sample “AutoDispatcher2.py” that is distributed with JMRI, figuring that

it HAS to work.

 

Problem:

 

Did someone change the parameters  to the implementation of “addpropertychangelistener”?

If so, I need an example .py code to see the new way, and I suspect

all of those samples need to be changed also…. (I hope not!)

 

 

Here’s the code and the failure from the “Green screen of death”:

(I stripped out most of the .py code, just the facts here):

 

import java

import java.awt

import java.awt.event

import java.beans

import java.io

import java.util

 

import jmri

from jmri import InstanceManager

from jmri import PowerManager

 

 

 

 

class CrossingInterlocking:

                def __init__(     self,

                                                                                                                                route1_occ, route2_occ, route3_occ, route4_occ, route5_occ, route6_occ,

                                                                                                                                xing_occ,

                                                                                                                                route1_stop, route2_stop, route3_stop, route4_stop, route5_stop, route6_stop):

 

                                self.powerManager = InstanceManager.getDefault(jmri.PowerManager)

                                print "A"

                                self.powerManager.addPropertyChangeListener(self)

                                print "B"

 

 

 

 

2019-09-05 22:10:01,877 util.Log4JUtil                        INFO  - ****** JMRI log ******* [main]

2019-09-05 22:10:01,897 util.Log4JUtil                        INFO  - This log is appended to file: C:\Users\NetBeansJMRI\JMRI\log\messages.log [main]

2019-09-05 22:10:01,898 util.Log4JUtil                        INFO  - This log is stored in file: C:\Users\NetBeansJMRI\JMRI\log\session.log [main]

2019-09-05 22:10:01,904 apps.Apps                             INFO  - PanelPro version 4.17.4ish+NetBeansJMRI+20190906T0309Z+R447bf29d1f starts under Java 1.8.0_181 on Windows 7 amd64 v6.1 at Thu Sep 05 22:10:01 CDT 2019 [main]

2019-09-05 22:10:03,378 apps.Apps                             INFO  - Starting with profile Jim_Osborn.3f49fc21 [main]

2019-09-05 22:10:03,540 node.NodeIdentity                     INFO  - Using 424d3839-25c1-11e9-8000-d4bed9986f79 as the JMRI storage identity for profile id 3f49fc21 [AWT-EventQueue-0]

2019-09-05 22:10:04,002 loconet.LnPacketizer                  INFO  - lnPacketizer Started [main]

2019-09-05 22:10:04,003 hexfile.LnHexFilePort                 INFO  - LocoNet Simulator Started [LocoNet HexFileFrame]

2019-09-05 22:10:04,183 apps.PerformFileModel                 INFO  - Loading file C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\JimOsborn.xml [main]

2019-09-05 22:10:06,091 script.JmriScriptEngineManager        INFO  - ECMAScript ECMA - 262 Edition 5.1 is provided by Oracle Nashorn 1.8.0_181 [AWT-EventQueue-0]

2019-09-05 22:10:06,096 script.JmriScriptEngineManager        INFO  - python 2.7 is provided by jython 2.7.0 [AWT-EventQueue-0]

2019-09-05 22:10:06,259 apps.PerformScriptModel               INFO  - Running script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py [main]

2019-09-05 22:10:08,945 script.JmriScriptEngineManager        ERROR - Error in script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py. [main]

javax.script.ScriptException: TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener in <script> at line number 80

                at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)

                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)

                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:47)

                at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)

                at jmri.script.JmriScriptEngineManager.eval(JmriScriptEngineManager.java:324)

                at jmri.script.JmriScriptEngineManager.runScript(JmriScriptEngineManager.java:388)

                at apps.PerformScriptModel.performAction(PerformScriptModel.java:32)

                at apps.StartupActionsManager.lambda$initialize$1(StartupActionsManager.java:120)

                at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)

                at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)

                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)

                at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)

                at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)

                at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)

                at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)

                at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)

                at java.util.stream.ReferencePipeline.forEachOrdered(ReferencePipeline.java:423)

                at apps.StartupActionsManager.initialize(StartupActionsManager.java:118)

                at jmri.implementation.JmriConfigurationManager.initializeProvider(JmriConfigurationManager.java:392)

                at jmri.implementation.JmriConfigurationManager.lambda$load$1(JmriConfigurationManager.java:205)

                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)

                at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)

                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:204)

                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:192)

                at apps.Apps.<init>(Apps.java:279)

                at apps.PanelPro.PanelPro.<init>(PanelPro.java:40)

                at apps.PanelPro.PanelPro.main(PanelPro.java:120)

Caused by: Traceback (most recent call last):

  File "<script>", line 80, in <module>

  File "<script>", line 28, in __init__

TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener

 

                at org.python.core.Py.TypeError(Py.java:259)

                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)

                at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)

                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)

                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:167)

                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)

                at org.python.core.PyObject.__call__(PyObject.java:478)

                at org.python.core.PyObject.__call__(PyObject.java:482)

                at org.python.core.PyMethod.__call__(PyMethod.java:141)

                at org.python.pycode._pyx0.__init__$2(<script>:58)

                at org.python.pycode._pyx0.call_function(<script>)

                at org.python.core.PyTableCode.call(PyTableCode.java:167)

                at org.python.core.PyBaseCode.call(PyBaseCode.java:307)

                at org.python.core.PyBaseCode.call(PyBaseCode.java:198)

                at org.python.core.PyFunction.__call__(PyFunction.java:482)

                at org.python.core.PyFunction.__call__(PyFunction.java:476)

                at org.python.core.PyInstance.__init__(PyInstance.java:124)

                at org.python.core.PyClass.__call__(PyClass.java:193)

                at org.python.core.PyObject.__call__(PyObject.java:431)

                at org.python.core.PyObject.__call__(PyObject.java:435)

                at org.python.pycode._pyx0.f$0(<script>:96)

                at org.python.pycode._pyx0.call_function(<script>)

                at org.python.core.PyTableCode.call(PyTableCode.java:167)

                at org.python.core.PyCode.call(PyCode.java:18)

                at org.python.core.Py.runCode(Py.java:1386)

                at org.python.core.__builtin__.eval(__builtin__.java:497)

                at org.python.core.__builtin__.eval(__builtin__.java:501)

                at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)

                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40)

                ... 25 more

2019-09-05 22:10:08,955 util.FileUtilSupport                  INFO  - File path program: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\ [main]

2019-09-05 22:10:08,956 util.FileUtilSupport                  INFO  - File path preference: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]

2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path profile: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]

2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path settings: is C:\Users\NetBeansJMRI\JMRI\ [main]

2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path home: is C:\Users\NetBeansJMRI\ [main]

2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path scripts: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\jython\ [main]

2019-09-05 22:10:09,175 PanelPro.PanelPro                     INFO  - Main initialization done [main]

 

Sincerely

 

Greg

 

Dave Sand
 

Greg,

Looks like the class line is incomplete although without seeing the whole script I might be wrong.

class Xyz(java.beans.PropertyChangeListener):


Dave


On Sep 5, 2019, at 10:25 PM, wombat_rrnut <gbedlek001@...> wrote:

I started developing a simple Jython program for a friend under JMRI.  I am running recent code set
4.17.4ish……. (Did a “sync” about a week ago with master).
 
Problem: calling “addpropertychangelistener” bombs.
Now, just like “AutoDispatcher2.py”, I have at least 50 of these calls to “addpropertychangelistener” that I’ve used
for the last 10+ years, but haven’t yet run with 4.17.4ish (nor can I easily test it).
 
So to eliminate the chance that I’m screwing up, I copied the code directly from the
supplied sample “AutoDispatcher2.py” that is distributed with JMRI, figuring that
it HAS to work.
 
Problem:
 
Did someone change the parameters  to the implementation of “addpropertychangelistener”?
If so, I need an example .py code to see the new way, and I suspect
all of those samples need to be changed also…. (I hope not!)
 
 
Here’s the code and the failure from the “Green screen of death”:
(I stripped out most of the .py code, just the facts here):
 
import java
import java.awt
import java.awt.event
import java.beans
import java.io
import java.util
 
import jmri
from jmri import InstanceManager
from jmri import PowerManager
 
 
 
 
class CrossingInterlocking:
                def __init__(     self,
                                                                                                                                route1_occ, route2_occ, route3_occ, route4_occ, route5_occ, route6_occ,
                                                                                                                                xing_occ,
                                                                                                                                route1_stop, route2_stop, route3_stop, route4_stop, route5_stop, route6_stop):
 
                                self.powerManager = InstanceManager.getDefault(jmri.PowerManager)
                                print "A"
                                self.powerManager.addPropertyChangeListener(self)
                                print "B"
 
 
 
 
2019-09-05 22:10:01,877 util.Log4JUtil                        INFO  - ****** JMRI log ******* [main]
2019-09-05 22:10:01,897 util.Log4JUtil                        INFO  - This log is appended to file: C:\Users\NetBeansJMRI\JMRI\log\messages.log [main]
2019-09-05 22:10:01,898 util.Log4JUtil                        INFO  - This log is stored in file: C:\Users\NetBeansJMRI\JMRI\log\session.log [main]
2019-09-05 22:10:01,904 apps.Apps                             INFO  - PanelPro version 4.17.4ish+NetBeansJMRI+20190906T0309Z+R447bf29d1f starts under Java 1.8.0_181 on Windows 7 amd64 v6.1 at Thu Sep 05 22:10:01 CDT 2019 [main]
2019-09-05 22:10:03,378 apps.Apps                             INFO  - Starting with profile Jim_Osborn.3f49fc21 [main]
2019-09-05 22:10:03,540 node.NodeIdentity                     INFO  - Using 424d3839-25c1-11e9-8000-d4bed9986f79 as the JMRI storage identity for profile id 3f49fc21 [AWT-EventQueue-0]
2019-09-05 22:10:04,002 loconet.LnPacketizer                  INFO  - lnPacketizer Started [main]
2019-09-05 22:10:04,003 hexfile.LnHexFilePort                 INFO  - LocoNet Simulator Started [LocoNet HexFileFrame]
2019-09-05 22:10:04,183 apps.PerformFileModel                 INFO  - Loading file C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\JimOsborn.xml [main]
2019-09-05 22:10:06,091 script.JmriScriptEngineManager        INFO  - ECMAScript ECMA - 262 Edition 5.1 is provided by Oracle Nashorn 1.8.0_181 [AWT-EventQueue-0]
2019-09-05 22:10:06,096 script.JmriScriptEngineManager        INFO  - python 2.7 is provided by jython 2.7.0 [AWT-EventQueue-0]
2019-09-05 22:10:06,259 apps.PerformScriptModel               INFO  - Running script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py [main]
2019-09-05 22:10:08,945 script.JmriScriptEngineManager        ERROR - Error in script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py. [main]
javax.script.ScriptException: TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener in <script> at line number 80
                at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:47)
                at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
                at jmri.script.JmriScriptEngineManager.eval(JmriScriptEngineManager.java:324)
                at jmri.script.JmriScriptEngineManager.runScript(JmriScriptEngineManager.java:388)
                at apps.PerformScriptModel.performAction(PerformScriptModel.java:32)
                at apps.StartupActionsManager.lambda$initialize$1(StartupActionsManager.java:120)
                at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
                at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
                at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
                at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
                at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
                at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
                at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.util.stream.ReferencePipeline.forEachOrdered(ReferencePipeline.java:423)
                at apps.StartupActionsManager.initialize(StartupActionsManager.java:118)
                at jmri.implementation.JmriConfigurationManager.initializeProvider(JmriConfigurationManager.java:392)
                at jmri.implementation.JmriConfigurationManager.lambda$load$1(JmriConfigurationManager.java:205)
                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
                at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:204)
                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:192)
                at apps.Apps.<init>(Apps.java:279)
                at apps.PanelPro.PanelPro.<init>(PanelPro.java:40)
                at apps.PanelPro.PanelPro.main(PanelPro.java:120)
Caused by: Traceback (most recent call last):
  File "<script>", line 80, in <module>
  File "<script>", line 28, in __init__
TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener
 
                at org.python.core.Py.TypeError(Py.java:259)
                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)
                at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)
                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)
                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:167)
                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
                at org.python.core.PyObject.__call__(PyObject.java:478)
                at org.python.core.PyObject.__call__(PyObject.java:482)
                at org.python.core.PyMethod.__call__(PyMethod.java:141)
                at org.python.pycode._pyx0.__init__$2(<script>:58)
                at org.python.pycode._pyx0.call_function(<script>)
                at org.python.core.PyTableCode.call(PyTableCode.java:167)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:307)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:198)
                at org.python.core.PyFunction.__call__(PyFunction.java:482)
                at org.python.core.PyFunction.__call__(PyFunction.java:476)
                at org.python.core.PyInstance.__init__(PyInstance.java:124)
                at org.python.core.PyClass.__call__(PyClass.java:193)
                at org.python.core.PyObject.__call__(PyObject.java:431)
                at org.python.core.PyObject.__call__(PyObject.java:435)
                at org.python.pycode._pyx0.f$0(<script>:96)
                at org.python.pycode._pyx0.call_function(<script>)
                at org.python.core.PyTableCode.call(PyTableCode.java:167)
                at org.python.core.PyCode.call(PyCode.java:18)
                at org.python.core.Py.runCode(Py.java:1386)
                at org.python.core.__builtin__.eval(__builtin__.java:497)
                at org.python.core.__builtin__.eval(__builtin__.java:501)
                at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40)
                ... 25 more
2019-09-05 22:10:08,955 util.FileUtilSupport                  INFO  - File path program: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\ [main]
2019-09-05 22:10:08,956 util.FileUtilSupport                  INFO  - File path preference: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]
2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path profile: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]
2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path settings: is C:\Users\NetBeansJMRI\JMRI\ [main]
2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path home: is C:\Users\NetBeansJMRI\ [main]
2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path scripts: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\jython\ [main]
2019-09-05 22:10:09,175 PanelPro.PanelPro                     INFO  - Main initialization done [main]
 
Sincerely
 
Greg
 

wombat_rrnut
 

Hold off on this.  Gathering more info.

 

Greg

From: jmri@jmri-developers.groups.io [mailto:jmri@jmri-developers.groups.io] On Behalf Of Dave Sand
Sent: Thursday, September 05, 2019 10:31 PM
To: jmri@jmri-developers.groups.io
Subject: Re: [jmri-developers] Having a problem with the Jython Interface..

 

Greg,

 

Looks like the class line is incomplete although without seeing the whole script I might be wrong.

 

class Xyz(java.beans.PropertyChangeListener):


Dave

 



On Sep 5, 2019, at 10:25 PM, wombat_rrnut <gbedlek001@...> wrote:

I started developing a simple Jython program for a friend under JMRI.  I am running recent code set
4.17.4ish……. (Did a “sync” about a week ago with master).
 
Problem: calling “addpropertychangelistener” bombs.
Now, just like “AutoDispatcher2.py”, I have at least 50 of these calls to “addpropertychangelistener” that I’ve used
for the last 10+ years, but haven’t yet run with 4.17.4ish (nor can I easily test it).
 
So to eliminate the chance that I’m screwing up, I copied the code directly from the
supplied sample “AutoDispatcher2.py” that is distributed with JMRI, figuring that
it HAS to work.
 
Problem:
 
Did someone change the parameters  to the implementation of “addpropertychangelistener”?
If so, I need an example .py code to see the new way, and I suspect
all of those samples need to be changed also…. (I hope not!)
 
 
Here’s the code and the failure from the “Green screen of death”:
(I stripped out most of the .py code, just the facts here):
 
import java
import java.awt
import java.awt.event
import java.beans
import java.io
import java.util
 
import jmri
from jmri import InstanceManager
from jmri import PowerManager
 
 
 
 
class CrossingInterlocking:
                def __init__(     self,
                                                                                                                                route1_occ, route2_occ, route3_occ, route4_occ, route5_occ, route6_occ,
                                                                                                                                xing_occ,
                                                                                                                                route1_stop, route2_stop, route3_stop, route4_stop, route5_stop, route6_stop):
 
                                self.powerManager = InstanceManager.getDefault(jmri.PowerManager)
                                print "A"
                                self.powerManager.addPropertyChangeListener(self)
                                print "B"
 
 
 
 
2019-09-05 22:10:01,877 util.Log4JUtil                        INFO  - ****** JMRI log ******* [main]
2019-09-05 22:10:01,897 util.Log4JUtil                        INFO  - This log is appended to file: C:\Users\NetBeansJMRI\JMRI\log\messages.log [main]
2019-09-05 22:10:01,898 util.Log4JUtil                        INFO  - This log is stored in file: C:\Users\NetBeansJMRI\JMRI\log\session.log [main]
2019-09-05 22:10:01,904 apps.Apps                             INFO  - PanelPro version 4.17.4ish+NetBeansJMRI+20190906T0309Z+R447bf29d1f starts under Java 1.8.0_181 on Windows 7 amd64 v6.1 at Thu Sep 05 22:10:01 CDT 2019 [main]
2019-09-05 22:10:03,378 apps.Apps                             INFO  - Starting with profile Jim_Osborn.3f49fc21 [main]
2019-09-05 22:10:03,540 node.NodeIdentity                     INFO  - Using 424d3839-25c1-11e9-8000-d4bed9986f79 as the JMRI storage identity for profile id 3f49fc21 [AWT-EventQueue-0]
2019-09-05 22:10:04,002 loconet.LnPacketizer                  INFO  - lnPacketizer Started [main]
2019-09-05 22:10:04,003 hexfile.LnHexFilePort                 INFO  - LocoNet Simulator Started [LocoNet HexFileFrame]
2019-09-05 22:10:04,183 apps.PerformFileModel                 INFO  - Loading file C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\JimOsborn.xml [main]
2019-09-05 22:10:06,091 script.JmriScriptEngineManager        INFO  - ECMAScript ECMA - 262 Edition 5.1 is provided by Oracle Nashorn 1.8.0_181 [AWT-EventQueue-0]
2019-09-05 22:10:06,096 script.JmriScriptEngineManager        INFO  - python 2.7 is provided by jython 2.7.0 [AWT-EventQueue-0]
2019-09-05 22:10:06,259 apps.PerformScriptModel               INFO  - Running script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py [main]
2019-09-05 22:10:08,945 script.JmriScriptEngineManager        ERROR - Error in script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py. [main]
javax.script.ScriptException: TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener in <script> at line number 80
                at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:47)
                at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
                at jmri.script.JmriScriptEngineManager.eval(JmriScriptEngineManager.java:324)
                at jmri.script.JmriScriptEngineManager.runScript(JmriScriptEngineManager.java:388)
                at apps.PerformScriptModel.performAction(PerformScriptModel.java:32)
                at apps.StartupActionsManager.lambda$initialize$1(StartupActionsManager.java:120)
                at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
                at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
                at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
                at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
                at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
                at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
                at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.util.stream.ReferencePipeline.forEachOrdered(ReferencePipeline.java:423)
                at apps.StartupActionsManager.initialize(StartupActionsManager.java:118)
                at jmri.implementation.JmriConfigurationManager.initializeProvider(JmriConfigurationManager.java:392)
                at jmri.implementation.JmriConfigurationManager.lambda$load$1(JmriConfigurationManager.java:205)
                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
                at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:204)
                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:192)
                at apps.Apps.<init>(Apps.java:279)
                at apps.PanelPro.PanelPro.<init>(PanelPro.java:40)
                at apps.PanelPro.PanelPro.main(PanelPro.java:120)
Caused by: Traceback (most recent call last):
  File "<script>", line 80, in <module>
  File "<script>", line 28, in __init__
TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener
 
                at org.python.core.Py.TypeError(Py.java:259)
                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)
                at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)
                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)
                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:167)
                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
                at org.python.core.PyObject.__call__(PyObject.java:478)
                at org.python.core.PyObject.__call__(PyObject.java:482)
                at org.python.core.PyMethod.__call__(PyMethod.java:141)
                at org.python.pycode._pyx0.__init__$2(<script>:58)
                at org.python.pycode._pyx0.call_function(<script>)
                at org.python.core.PyTableCode.call(PyTableCode.java:167)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:307)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:198)
                at org.python.core.PyFunction.__call__(PyFunction.java:482)
                at org.python.core.PyFunction.__call__(PyFunction.java:476)
                at org.python.core.PyInstance.__init__(PyInstance.java:124)
                at org.python.core.PyClass.__call__(PyClass.java:193)
                at org.python.core.PyObject.__call__(PyObject.java:431)
                at org.python.core.PyObject.__call__(PyObject.java:435)
                at org.python.pycode._pyx0.f$0(<script>:96)
                at org.python.pycode._pyx0.call_function(<script>)
                at org.python.core.PyTableCode.call(PyTableCode.java:167)
                at org.python.core.PyCode.call(PyCode.java:18)
                at org.python.core.Py.runCode(Py.java:1386)
                at org.python.core.__builtin__.eval(__builtin__.java:497)
                at org.python.core.__builtin__.eval(__builtin__.java:501)
                at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40)
                ... 25 more
2019-09-05 22:10:08,955 util.FileUtilSupport                  INFO  - File path program: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\ [main]
2019-09-05 22:10:08,956 util.FileUtilSupport                  INFO  - File path preference: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]
2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path profile: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]
2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path settings: is C:\Users\NetBeansJMRI\JMRI\ [main]
2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path home: is C:\Users\NetBeansJMRI\ [main]
2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path scripts: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\jython\ [main]
2019-09-05 22:10:09,175 PanelPro.PanelPro                     INFO  - Main initialization done [main]
 
Sincerely
 
Greg
 

 

wombat_rrnut
 

Dave/All:

 

My bad: I forgot that (java.beans.PropertyChangeListener) in the class declaration.

 

Sorry about that.  Case close.

 

Greg

 

 

From: jmri@jmri-developers.groups.io [mailto:jmri@jmri-developers.groups.io] On Behalf Of wombat_rrnut
Sent: Friday, September 06, 2019 7:03 AM
To: jmri@jmri-developers.groups.io
Subject: Re: [jmri-developers] Having a problem with the Jython Interface..

 

Hold off on this.  Gathering more info.

 

Greg

From: jmri@jmri-developers.groups.io [mailto:jmri@jmri-developers.groups.io] On Behalf Of Dave Sand
Sent: Thursday, September 05, 2019 10:31 PM
To: jmri@jmri-developers.groups.io
Subject: Re: [jmri-developers] Having a problem with the Jython Interface..

 

Greg,

 

Looks like the class line is incomplete although without seeing the whole script I might be wrong.

 

class Xyz(java.beans.PropertyChangeListener):


Dave

 

 

On Sep 5, 2019, at 10:25 PM, wombat_rrnut <gbedlek001@...> wrote:

I started developing a simple Jython program for a friend under JMRI.  I am running recent code set
4.17.4ish……. (Did a “sync” about a week ago with master).
 
Problem: calling “addpropertychangelistener” bombs.
Now, just like “AutoDispatcher2.py”, I have at least 50 of these calls to “addpropertychangelistener” that I’ve used
for the last 10+ years, but haven’t yet run with 4.17.4ish (nor can I easily test it).
 
So to eliminate the chance that I’m screwing up, I copied the code directly from the
supplied sample “AutoDispatcher2.py” that is distributed with JMRI, figuring that
it HAS to work.
 
Problem:
 
Did someone change the parameters  to the implementation of “addpropertychangelistener”?
If so, I need an example .py code to see the new way, and I suspect
all of those samples need to be changed also…. (I hope not!)
 
 
Here’s the code and the failure from the “Green screen of death”:
(I stripped out most of the .py code, just the facts here):
 
import java
import java.awt
import java.awt.event
import java.beans
import java.io
import java.util
 
import jmri
from jmri import InstanceManager
from jmri import PowerManager
 
 
 
 
class CrossingInterlocking:
                def __init__(     self,
                                                                                                                                route1_occ, route2_occ, route3_occ, route4_occ, route5_occ, route6_occ,
                                                                                                                                xing_occ,
                                                                                                                                route1_stop, route2_stop, route3_stop, route4_stop, route5_stop, route6_stop):
 
                                self.powerManager = InstanceManager.getDefault(jmri.PowerManager)
                                print "A"
                                self.powerManager.addPropertyChangeListener(self)
                                print "B"
 
 
 
 
2019-09-05 22:10:01,877 util.Log4JUtil                        INFO  - ****** JMRI log ******* [main]
2019-09-05 22:10:01,897 util.Log4JUtil                        INFO  - This log is appended to file: C:\Users\NetBeansJMRI\JMRI\log\messages.log [main]
2019-09-05 22:10:01,898 util.Log4JUtil                        INFO  - This log is stored in file: C:\Users\NetBeansJMRI\JMRI\log\session.log [main]
2019-09-05 22:10:01,904 apps.Apps                             INFO  - PanelPro version 4.17.4ish+NetBeansJMRI+20190906T0309Z+R447bf29d1f starts under Java 1.8.0_181 on Windows 7 amd64 v6.1 at Thu Sep 05 22:10:01 CDT 2019 [main]
2019-09-05 22:10:03,378 apps.Apps                             INFO  - Starting with profile Jim_Osborn.3f49fc21 [main]
2019-09-05 22:10:03,540 node.NodeIdentity                     INFO  - Using 424d3839-25c1-11e9-8000-d4bed9986f79 as the JMRI storage identity for profile id 3f49fc21 [AWT-EventQueue-0]
2019-09-05 22:10:04,002 loconet.LnPacketizer                  INFO  - lnPacketizer Started [main]
2019-09-05 22:10:04,003 hexfile.LnHexFilePort                 INFO  - LocoNet Simulator Started [LocoNet HexFileFrame]
2019-09-05 22:10:04,183 apps.PerformFileModel                 INFO  - Loading file C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\JimOsborn.xml [main]
2019-09-05 22:10:06,091 script.JmriScriptEngineManager        INFO  - ECMAScript ECMA - 262 Edition 5.1 is provided by Oracle Nashorn 1.8.0_181 [AWT-EventQueue-0]
2019-09-05 22:10:06,096 script.JmriScriptEngineManager        INFO  - python 2.7 is provided by jython 2.7.0 [AWT-EventQueue-0]
2019-09-05 22:10:06,259 apps.PerformScriptModel               INFO  - Running script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py [main]
2019-09-05 22:10:08,945 script.JmriScriptEngineManager        ERROR - Error in script C:\Program Files (x86)\JMRI\jython\OtherPeopleSource\JimOsborn.py. [main]
javax.script.ScriptException: TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener in <script> at line number 80
                at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:47)
                at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
                at jmri.script.JmriScriptEngineManager.eval(JmriScriptEngineManager.java:324)
                at jmri.script.JmriScriptEngineManager.runScript(JmriScriptEngineManager.java:388)
                at apps.PerformScriptModel.performAction(PerformScriptModel.java:32)
                at apps.StartupActionsManager.lambda$initialize$1(StartupActionsManager.java:120)
                at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
                at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
                at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
                at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
                at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
                at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
                at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.util.stream.ReferencePipeline.forEachOrdered(ReferencePipeline.java:423)
                at apps.StartupActionsManager.initialize(StartupActionsManager.java:118)
                at jmri.implementation.JmriConfigurationManager.initializeProvider(JmriConfigurationManager.java:392)
                at jmri.implementation.JmriConfigurationManager.lambda$load$1(JmriConfigurationManager.java:205)
                at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
                at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:204)
                at jmri.implementation.JmriConfigurationManager.load(JmriConfigurationManager.java:192)
                at apps.Apps.<init>(Apps.java:279)
                at apps.PanelPro.PanelPro.<init>(PanelPro.java:40)
                at apps.PanelPro.PanelPro.main(PanelPro.java:120)
Caused by: Traceback (most recent call last):
  File "<script>", line 80, in <module>
  File "<script>", line 28, in __init__
TypeError: addPropertyChangeListener(): 1st arg can't be coerced to java.beans.PropertyChangeListener
 
                at org.python.core.Py.TypeError(Py.java:259)
                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)
                at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)
                at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)
                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:167)
                at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
                at org.python.core.PyObject.__call__(PyObject.java:478)
                at org.python.core.PyObject.__call__(PyObject.java:482)
                at org.python.core.PyMethod.__call__(PyMethod.java:141)
                at org.python.pycode._pyx0.__init__$2(<script>:58)
                at org.python.pycode._pyx0.call_function(<script>)
                at org.python.core.PyTableCode.call(PyTableCode.java:167)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:307)
                at org.python.core.PyBaseCode.call(PyBaseCode.java:198)
                at org.python.core.PyFunction.__call__(PyFunction.java:482)
                at org.python.core.PyFunction.__call__(PyFunction.java:476)
                at org.python.core.PyInstance.__init__(PyInstance.java:124)
                at org.python.core.PyClass.__call__(PyClass.java:193)
                at org.python.core.PyObject.__call__(PyObject.java:431)
                at org.python.core.PyObject.__call__(PyObject.java:435)
                at org.python.pycode._pyx0.f$0(<script>:96)
                at org.python.pycode._pyx0.call_function(<script>)
                at org.python.core.PyTableCode.call(PyTableCode.java:167)
                at org.python.core.PyCode.call(PyCode.java:18)
                at org.python.core.Py.runCode(Py.java:1386)
                at org.python.core.__builtin__.eval(__builtin__.java:497)
                at org.python.core.__builtin__.eval(__builtin__.java:501)
                at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
                at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40)
                ... 25 more
2019-09-05 22:10:08,955 util.FileUtilSupport                  INFO  - File path program: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\ [main]
2019-09-05 22:10:08,956 util.FileUtilSupport                  INFO  - File path preference: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]
2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path profile: is C:\Users\NetBeansJMRI\JMRI\Jim_Osborn.jmri\ [main]
2019-09-05 22:10:08,958 util.FileUtilSupport                  INFO  - File path settings: is C:\Users\NetBeansJMRI\JMRI\ [main]
2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path home: is C:\Users\NetBeansJMRI\ [main]
2019-09-05 22:10:08,959 util.FileUtilSupport                  INFO  - File path scripts: is C:\Users\NetBeansJMRI\Documents\NetBeansProjects\JMRI\jython\ [main]
2019-09-05 22:10:09,175 PanelPro.PanelPro                     INFO  - Main initialization done [main]
 
Sincerely
 
Greg