Menu

#11 Problem when running on Jython

open
nobody
None
5
2012-09-23
2009-06-21
thijs
No

Hi there,

I'm trying to get the JFlashPlayer component to run in Jython but I'm getting the error below. This doesn't make sense to me since your Java examples also don't pass in any params, so I'm thinking it's either a bug in this library, or Jython itself, but before reporting there I was wondering if you could give it a try as well and/or have a workaround. See the attached file, and run 'jython jython_flash.py' to start the example.

$ jython jython_flash.py
Traceback (most recent call last):
File "jython_flash.py", line 66, in <module>
app = AppGUI(title)
File "jython_flash.py", line 18, in init
self.create_gui()
File "jython_flash.py", line 35, in create_gui
flashPlayer = JFlashPlayer()
TypeError: _new_impl(): expected 1 args; got 0

Discussion

  • thijs

    thijs - 2009-06-21
     
  • Christopher Deckers

    I don't know anything about Jython, I never tried it. But if the library is used correctly, then I don't see why it would not work.

    Nevertheless, I looked at the file you provided and I noticed 2 things:
    - NativeInterface.open() is never called, though it should be the first statement of the main method.
    - AppGui does not seem to be created in the UI thread (using SwingUtilities.invokeLater in standard Java).

    Could you modify your code to comply with the 2 points above and let me know if it improves the situation?

    Cheers,
    -Christopher

     
  • thijs

    thijs - 2009-06-22
     
  • thijs

    thijs - 2009-06-22

    I added an updated version, and I hope I addressed your questions, but I'm still getting the same error. I'm now almost convinced it's a Jython 2.5.0 final issue..

     
  • Christopher Deckers

    I looked at your new example, and while I don't know anything about Jython I think the code looks OK.
    I have several comments though. Looking at the original error, I see "TypeError: _new_impl(): expected 1 args; got 0" which is somewhat right. The JFlashPlayer, as well as all the Native Swing components, have a constructor with variable arguments. Maybe Jython expects the explicit declaration of the array of options even if empty (a NSOption[]).
    Also, I see you are using 0.9.8 but if you plan on using Java 6 u10+, I would recommend getting 0.9.9 preview from the SourceForge download section and upgrading to 6u14 (u10-u13 are problematic releases).

    -Christopher

     
  • Nobody/Anonymous

    Thanks for your help Christopher, I will log a new ticket in the Jython bugtracker, and keep this open in case it's a JFlashPlayer issue afterall. I am using the latest OSX for development and as far as I know this comes with java 1.6u13 since the last update a few days ago.. We'll see how it goes once I have JFlashPlayer working under Jython :)

     
  • Christopher Deckers

    You say you are using OSX? Then the bug is simply that OSX is not supported yet, mainly because of an SWT bug:
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=246929

    I would recommend you vote for that bug if you want to help push for an OSX support...

     
  • Nobody/Anonymous

    Thanks for the link, I added my vote. I should note that the same happens on a Windows XP machine with jdk 1.6u14.

     
  • thijs

    thijs - 2009-07-02

    Logged a Jython ticket: http://bugs.jython.org/issue1393

     
  • thijs

    thijs - 2009-08-26

    The Jython ticket (http://bugs.jython.org/issue1393) has now been resolved but the Eclipse bug hasn't seen much progress. I'll check the sample with the latest Jython and report the new error message.

     
  • Christopher Deckers

    The new error seems to be an issue with Native Swing (it seems to fail to load an image resource). I changed something related to this in the 0.9.9 preview, so I would be grateful if you could try this preview (available in the download section) and let me know what next error you get :)

    -Christopher

     
  • thijs

    thijs - 2009-08-26

    I tested with the latest Jython (r6723) and DJNativeSwing-SWT-0-9-9-20090811 and now getting a sane error message:

    sys-package-mgr: processing new jar, '/Volumes/collab/Sites/software/jython/DJNativeSwing-SWT-0-9-9-20090811/DJNativeSwing-SWT.jar'
    sys-package-mgr: processing new jar, '/Volumes/collab/Sites/software/jython/DJNativeSwing-SWT-0-9-9-20090811/DJNativeSwing-SWTDemo.jar'
    sys-package-mgr: processing new jar, '/Volumes/collab/Sites/software/jython/DJNativeSwing-SWT-0-9-9-20090811/DJNativeSwing.jar'
    Traceback (most recent call last):
    File "/Users/thijstriemstra/Downloads/jython_flash.py", line 58, in <module>
    app = SimpleFlashExample()
    File "/Users/thijstriemstra/Downloads/jython_flash.py", line 21, in init
    flashPlayer = JFlashPlayer()
    TypeError: chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer(): expected 1 args; got 0

    Unfortunately it still throws the nullpointer exception when an empty array is passed in:
    Traceback (most recent call last):
    File "/Users/thijstriemstra/Downloads/jython_flash.py", line 59, in <module>
    app = SimpleFlashExample()
    File "/Users/thijstriemstra/Downloads/jython_flash.py", line 21, in init
    flashPlayer = JFlashPlayer([])
    at javax.swing.ImageIcon.<init>(ImageIcon.java:167)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.createIcon(DefaultWebBrowserDecorator.java:534)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.access$7(DefaultWebBrowserDecorator.java:532)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:245)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:518)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:97)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:167)
    at chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer.<init>(JFlashPlayer.java:126)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:163)

    java.lang.NullPointerException: java.lang.NullPointerException

    I'm using this swt btw, I know it's for windows but couldn't find one for osx (obviously?): swt-3.5RC1-win32-win32-x86.jar

     
  • Christopher Deckers

    The error you have is surprising: it seems it loaded the resource bundle properly (or else you would have a MissingResourceException) but it does not contain the key ViewMenuBackIcon. If you have any idea why this happens in your environment (or if you could debug in DefaultWebBrowserDecorator what RESOURCES contains when line 245 is reached) that would definitely help.

    -Christopher

     
  • thijs

    thijs - 2009-08-26

    ImageIcon example

     
  • thijs

    thijs - 2009-08-26

    I attached a sample that shows a ImageIcon and that works with Jython.. not sure how to debug this otherwise atm.

     

Log in to post a comment.