[
https://issues.apache.org/jira/browse/PIVOT-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13745656#comment-13745656
]
Sandro Martini edited comment on PIVOT-917 at 8/21/13 10:17 AM:
----------------------------------------------------------------
Jose, under Pivot-Stuff, I created a sample project with your files but updated
for my environment (Windows batch files to run the example) ... you can find
all here:
http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-jython
Under test/pivot_stuff/common_jython you can find a minimal example for Swing
(that works) and HelloBXML and related bxml file for Pivot, but currently in my
environment (Windows 8, both with latest JDK 6 and latest JDK 7) I got the
error at the end of this comment, with an initial warning on Preferences that
could be due to some restriction (probably in Java on win 8 when a class
without package tries to save Preferences because for example I get the same
error even when running latest Groovy Console in the same PC) to write entries
in the Windows registry, even if I am an administrator of the PC, we have to
check ... at least in another Windows environment (currently I have problems to
get some Linux VM).
Under _scripts there are some batch files to run examples, but they are not
completely general because they contain some references to my environment, but
changing env vars should be enough on a Windows PC ... or could you adapt your
scripts to my approach (executing java having only Jython jar in the CLASSPATH,
without having Jython installed in the PC, like a real deploy of a RIA via web)
?
Of course I could try even installing Jython in my env, but this could be good
only for dev environment (and not for real users) ...
Anyway, when a Pivot app starts, it tries to save some data using java
Preferences (and depending on the platform should save in the file system or in
the registry, if I remember well) ... we have a fallback so application can
proceed even in case of error like in this case (but tried the same example in
pure Java without Jython and all works ... could be a Jython/Preferences issue
when running applications without a package).
Probably to solve the problem here more than all classes inside a single script
(I have to try to do the same in a Groovy script), we could try to split (like
in Java) 1 class per file ... what do you think ? Have you got some Jython
example for this ?
Some discussion here (but related to Groovy Scripting):
http://apache-pivot-users.399431.n3.nabble.com/Using-pivot-from-JVM-based-scripting-languages-td4022336.html
Last, in your sample, at the bottom there is a block where you call:
SwingUtilities.invokeAndWait(Task(sys.argv[1:]))
are you sure that we need this ?
What do you think ? Suggestions, comments ?
Thank you very much.
My Error (with the jvm process blocked, I have to kill by hand):
ago 21, 2013 1:23:59 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root
0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.lang.ClassNotFoundException: org.python.proxies.__main__$HelloBXML$1
at
org.python.core.SyspathJavaLoader.findClass(SyspathJavaLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at
org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:606)
at
org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:881)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:404)
at org.python.core.PyObject.__call__(PyObject.java:408)
at
org.python.pycode._pyx0.run$9(../test/pivot_stuff/common_jython/HelloBXML.py:40)
at
org.python.pycode._pyx0.call_function(../test/pivot_stuff/common_jython/HelloBXML.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
at org.python.core.PyFunction.__call__(PyFunction.java:387)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
at org.python.core.PyMethod.__call__(PyMethod.java:211)
at org.python.core.PyMethod.__call__(PyMethod.java:201)
at org.python.core.PyMethod.__call__(PyMethod.java:196)
at org.python.core.PyObject._jcallexc(PyObject.java:3502)
at org.python.core.PyObject._jcall(PyObject.java:3534)
at org.python.proxies.__main__$Task$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Note that this:
at
org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:606)
map to this line in source code:
Class<?> applicationClass = Class.forName(applicationClassName);
where applicationClassName is the full class name of (User) Application main
class.
was (Author: smartini):
Jose, under Pivot-Stuff, I created a sample project with your files but
updated for my environment (Windows batch files to run the example) ... you can
find all here:
http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-jython
Under test/pivot_stuff/common_jython you can find a minimal example for Swing
(that works) and HelloBXML and related bxml file for Pivot, but currently in my
environment (Windows 8, both with latest JDK 6 and latest JDK 7) I got the
error at the end of this comment, with an initial warning on Preferences that
could be due to some restriction (probably in Java on win 8 when a class
without package tries to save Preferences because for example I get the same
error even when running latest Groovy Console in the same PC) to write entries
in the Windows registry, even if I am an administrator of the PC, we have to
check ... at least in another Windows environment (currently I have problems to
get some Linux VM).
Under _scripts there are some batch files to run examples, but they are not
completely general because they contain some references to my environment, but
changing env vars should be enough on a Windows PC ... or could you adapt your
scripts to my approach (executing java having only Jython jar in the CLASSPATH,
without having Jython installed in the PC, like a real deploy of a RIA via web)
?
Of course I could try even installing Jython in my env, but this could be good
only for dev environment (and not for real users) ...
Anyway, when a Pivot app starts, it tries to save some data using java
Preferences (and depending on the platform should save in the file system or in
the registry, if I remember well) ... we have a fallback so application can
proceed even in case of error like in this case (but tried the same example in
pure Java without Jython and all works ... could be a Jython/Preferences issue
when running applications without a package).
Probably to solve the problem here more than all classes inside a single script
(I have to try to do the same in a Groovy script), we could try to split (like
in Java) 1 class per file ... what do you think ? Have you got some Jython
example for this ?
Last, in your sample, at the bottom there is a block where you call:
SwingUtilities.invokeAndWait(Task(sys.argv[1:]))
are you sure that we need this ?
What do you think ? Suggestions, comments ?
Thank you very much.
My Error (with the jvm process blocked, I have to kill by hand):
ago 21, 2013 1:23:59 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root
0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.lang.ClassNotFoundException: org.python.proxies.__main__$HelloBXML$1
at
org.python.core.SyspathJavaLoader.findClass(SyspathJavaLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at
org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:606)
at
org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:881)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:404)
at org.python.core.PyObject.__call__(PyObject.java:408)
at
org.python.pycode._pyx0.run$9(../test/pivot_stuff/common_jython/HelloBXML.py:40)
at
org.python.pycode._pyx0.call_function(../test/pivot_stuff/common_jython/HelloBXML.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
at org.python.core.PyFunction.__call__(PyFunction.java:387)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
at org.python.core.PyMethod.__call__(PyMethod.java:211)
at org.python.core.PyMethod.__call__(PyMethod.java:201)
at org.python.core.PyMethod.__call__(PyMethod.java:196)
at org.python.core.PyObject._jcallexc(PyObject.java:3502)
at org.python.core.PyObject._jcall(PyObject.java:3534)
at org.python.proxies.__main__$Task$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Note that this:
at
org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:606)
map to this line in source code:
Class<?> applicationClass = Class.forName(applicationClassName);
where applicationClassName is the full class name of (User) Application main
class.
> Pivot cannot find inner classes in the CLASSPATH when invoked from Jython
> -------------------------------------------------------------------------
>
> Key: PIVOT-917
> URL: https://issues.apache.org/jira/browse/PIVOT-917
> Project: Pivot
> Issue Type: Bug
> Components: pivot-on-apache-extras
> Affects Versions: 2.0.3
> Reporter: Jose V Nunez
> Assignee: Sandro Martini
> Labels: jython
> Attachments: HelloBXML.py
>
>
> The following is similar to the simple Hello world BXML from the PIVOT
> website (http://pivot.apache.org/tutorials/hello-bxml.html, file hello.bxml
> content is identical):
> {code}
> #!/usr/bin/env jython
> from org.apache.pivot.beans import BXMLSerializer
> from org.apache.pivot.collections import Map
> from org.apache.pivot.wtk import Application
> from org.apache.pivot.wtk import Display
> from org.apache.pivot.wtk import Window
> from org.apache.pivot.wtk import DesktopApplicationContext
> from java.lang import Runnable, Exception as Ex
> from javax.swing import SwingUtilities
> import sys,subprocess,os,re, traceback
> class HelloBXML(Application):
> def __init__(self):
> self.window = None
> self.bxmlSerializer = BXMLSerializer()
> def startup(self, display, properties):
> self.window = self.bxmlSerializer.readObject(HelloBXML,
> "hello.bxml")
> self.window.open(display)
> def shutdown(self, optional):
> if self.window != null:
> window.close()
> return False;
> def suspend(self):
> pass
> def resume(self):
> pass
> class Task(Runnable):
> def __init__(self, argv):
> self.argv = argv
> def run(self):
> DesktopApplicationContext.main(HelloBXML, self.argv)
> if __name__ == "__main__":
> try:
> SwingUtilities.invokeAndWait(Task(sys.argv[1:]))
> except:
> traceback.print_exc(file=sys.stderr)
> sys.exit(192)
> {code}
> Exception stack trace:
> {code}
> # Script file: ~/HelloBXML.py
> java.lang.ClassNotFoundException: org.python.proxies.__main__$HelloBXML$1
> at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:186)
> at
> org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:606)
> at
> org.apache.pivot.wtk.DesktopApplicationContext.main(DesktopApplicationContext.java:881)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
> at
> org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
> at org.python.core.PyObject.__call__(PyObject.java:404)
> at org.python.core.PyObject.__call__(PyObject.java:408)
> at org.python.pycode._pyx0.run$9(/home/jnunezzu/HelloBXML.py:39)
> at org.python.pycode._pyx0.call_function(/home/jnunezzu/HelloBXML.py)
> at org.python.core.PyTableCode.call(PyTableCode.java:165)
> at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
> at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
> at org.python.core.PyFunction.__call__(PyFunction.java:387)
> at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
> at org.python.core.PyMethod.__call__(PyMethod.java:211)
> at org.python.core.PyMethod.__call__(PyMethod.java:201)
> at org.python.core.PyMethod.__call__(PyMethod.java:196)
> at org.python.core.PyObject._jcallexc(PyObject.java:3502)
> at org.python.core.PyObject._jcall(PyObject.java:3534)
> at org.python.proxies.__main__$Task$2.run(Unknown Source)
> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241)
> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
> at java.awt.EventQueue.access$000(EventQueue.java:101)
> at java.awt.EventQueue$3.run(EventQueue.java:666)
> at java.awt.EventQueue$3.run(EventQueue.java:664)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
> at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
> at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
> {code}
> I tested this with the following configuration:
> {code}
> Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
> [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0
> Type "help", "copyright", "credits" or "license" for more information.
> java -version
> java version "1.7.0"
> Java(TM) SE Runtime Environment (build 1.7.0-b147)
> Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
> uname -a
> Linux XXXX 2.6.18-348.3.1.el5 #1 SMP Tue Mar 5 13:19:32 EST 2013 x86_64
> x86_64 x86_64 GNU/Linux
> echo $CLASSPATH
> /home/jose/src/apache-pivot-2.0.3/lib/hello.bxml:/home/jose/src/apache-pivot-2.0.3/lib/pivot-wtk-terra-2.0.3.jar:/home/jose/src/apache-pivot-2.0.3/lib/pivot-wtk-2.0.3.jar:/home/jose/src/apache-pivot-2.0.3/lib/pivot-web-server-2.0.3.jar:/home/jose/src/apache-pivot-2.0.3/lib/pivot-web-2.0.3.jar:/home/jose/src/apache-pivot-2.0.3/lib/pivot-core-2.0.3.jar:/home/jose/src/apache-pivot-2.0.3/lib/pivot-charts-2.0.3.jar::.
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira