Dear All,
I am new to Jython and decided to try the code supplied in the monthly Newsletters of September and October 2006 as I want to be able to write some object factories for Python classes.
I am coding and testing in Eclipse vsn 3.5.1 with PyDev plugin installed, Jython 2.5.1 and JRE 6
I copied the code from the newsletters and changed the classes that differed between the two newsletters to have either Sep or Oct in them to distinguish where they came from. I have spent ages trying to find the problem and getting nowhere. One suggestion in an earlier post was to include into the python class
import sys
sys.add_package(' java package' ) - so I added this code as well for the java package 'jyinterface.interfaces'
but to no avail, same NullPointerException & ExceptionInInitializerError.
The only differences between my code and the code provided by Charlie Groves and Josh Juneau are java class name changes (MainSep.java, MainOct.java in package jyinterface.interfaces, EmployeeOct.py and EmployeeSep.py in the Jython project and I put MainSep.java not in package jyinterface as Josh had, but in the jyinterface.interfaces package). I also updated the references to these classes.
Here is the console output I get. Happy to supply the code if anyone feels kind enough to have a look!
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.python.core.PyObject.<clinit>(PyObject.java:26)
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:72)
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:60)
at jyinterface.factory.EmployeeFactory.<init>(EmployeeFactory.java:13)
at jyinterface.interfaces.MainOct.main(MainOct.java:18)
Caused by: java.lang.NullPointerException
at org.python.core.PyType.init(PyType.java:458)
at org.python.core.PyType.createType(PyType.java:1175)
at org.python.core.PyType.addFromClass(PyType.java:1116)
at org.python.core.PyType.fromClass(PyType.java:1182)
at org.python.core.PyType.<clinit>(PyType.java:30)
... 5 more
The lines that are being referred to in the error log are
MainOct.java:18
EmployeeFactory factory = new EmployeeFactory();
EmployeeFactory.java:13
PythonInterpreter interpreter = new PythonInterpreter();
PythonInterpreter.java:60
public PythonInterpreter() { // line 59
this(null, null); // line 60
PythonInterpreter.java:72
dict = new PyStringMap();
PyObject.java:26
public static final PyType TYPE = PyType.fromClass(PyObject.class);
PyType.java:458
if (!Py.BOOTSTRAP_TYPES.contains(underlying_class)) {
PyType.java:1175
newtype.init(c,needsInners);
PyType.java:1116
return createType(c, needsInners);
PyType.java:1182
addFromClass(PyType.class, null);
PyType.java:30
public static PyType TYPE = fromClass(PyType.class);
Cheers,
Sandra