Hello,

I've been struggling for over a month now to try to get Eclipse to recognize Jython classes within Java when my plugin is activated. I've posted several times to Stack Overflow with the PyDev tag but haven't gotten much in the way of responses so I thought I'd give this a try.

Even if you don't have an answer for me, I'd appreciate a quick reply so I know this email hasn't simply gone to the bit bucket.

I'm using the JythonObjectFactory described in http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications.

When I run a JUnit test in an Eclipse plugin (not a JUnit-Plugin test and so I'm not activating the plugin), the factory works just fine. When I call validateFactory.createObject(), I can cast it to the Java Interface I wrote and everyone is happy. 

When I try to do the same thing when I activate the plugin (via a product run configuration), I get the error:
java.lang.ClassCastException: org.python.core.PySingleton cannot be cast to com.myorg.MyInterface. 

When I run the unit test, if I call 
System.out.println(validateFactory.createObject().getClass().getName()); 
the output is
org.python.proxies.MyInterfaceDefinition$MyInterfaceDefinition$3
MyInterfaceDefinition is a Jython module that defines a class MyInterfaceDefinition that inherits from com.myorg.MyInterface
but when I do the same call from my plugin, the output is:
org.python.core.PySingleton

Does this ring any bells for anyone?

Thanks for taking a look at this.

Mason Wardle


P.S. Here's a little background info:

I'm running in Eclipse 3.8.1 on Linux using PyDev 2.5.7. 

Note that in order to get this far with the plugin, I had to create a Jython plugin from the jython-2.5.3 jar and make it a dependency in my plugin. I also had to manually set JYTHONPATH in environment variables in the run configuration and append to sys.path in my Jython module, both are things that seem to be automatically done by the PyDev plugin when running my JUnit test.