Message13028

Author Sunil1993
Recipients Sunil1993
Date 2020-04-20.06:09:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587362996.45.0.12023202344.issue2876@roundup.psfhosted.org>
In-reply-to
Content
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;
    }
}
History
Date User Action Args
2020-04-20 06:09:56Sunil1993setrecipients: + Sunil1993
2020-04-20 06:09:56Sunil1993setmessageid: <1587362996.45.0.12023202344.issue2876@roundup.psfhosted.org>
2020-04-20 06:09:56Sunil1993linkissue2876 messages
2020-04-20 06:09:56Sunil1993create