Issue2876
Created on 2020-04-20.06:09:56 by Sunil1993, last changed 2020-04-20.06:11:09 by Sunil1993.
msg13028 (view) |
Author: Sunil (Sunil1993) |
Date: 2020-04-20.06:09:56 |
|
I am trying to integrate jython in my spring boot project. It is working for me in with Intellij but when I deploy jar for testing I keep getting null pointer exception from the library.
I am using java 8.
Exception:
java.lang.NullPointerException: null
at org.python.core.PyModule.module___init__(PyModule.java:64) ~[jython-standalone-2.7.2.jar!\/:2.7.2]
at org.python.core.PyModule.<init>(PyModule.java:47) ~[jython-standalone-2.7.2.jar!\/:2.7.2]
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:104) ~[jython-standalone-2.7.2.jar!\/:2.7.2]
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:93) ~[jython-standalone-2.7.2.jar!\/:2.7.2]
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:70)
JythonFactoryFile:
public class JythonObjectFactory {
private static JythonObjectFactory instance = null;
private static PyObject pyObject = null;
protected JythonObjectFactory() {
}
public static JythonObjectFactory getInstance(){
if(instance == null){
instance = new JythonObjectFactory();
}
return instance;
}
public Object createObject(Object interfaceType, String moduleName){
Object javaInt = null;
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("from " + moduleName + " import " + moduleName);
pyObject = interpreter.get(moduleName);
try {
PyObject newObj = pyObject.__call__();
javaInt = newObj.__tojava__(Class.forName(interfaceType.toString().substring(
interfaceType.toString().indexOf(" ")+1, interfaceType.toString().length())));
} catch (ClassNotFoundException ex) {
log.error(JythonObjectFactory.class.getName() + " error: " + ex.getMessage(), ex);
}
return javaInt;
}
}
|
|
Date |
User |
Action |
Args |
2020-04-20 06:11:09 | Sunil1993 | set | title: Null pointer exception PyModule.java -> NullPointer exception PyModule.java |
2020-04-20 06:09:56 | Sunil1993 | create | |
|