|
From: George K. T. <gk...@to...> - 2001-02-13 17:59:12
|
I have a program that works when I run it standalone using jython:
import os
import os.path
import sys
from java.lang import System
def go(out):
title = "Example Apache JServ Servlet"
out = System.out
cwd = os.getcwd()
addedDir = os.path.join(cwd, 'Python')
out.println( 'current working directory = %s' % cwd)
out.println( 'directory to add = %s' % addedDir)
out.println( 'old path = %s' % sys.path)
sys.path.append(addedDir)
import Test2a
out.println( 'new path = %s' % sys.path)
out.println( 'now loading Test2a class and creating instance')
out.println( 'object = %s' % Test2a.Test2a() )
out.close()
if __name__ == '__main__':
out = System.out
go(out)
When I run it through the PythonInterpreter using this wrapper:
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class Test2Run {
public static void main(String []args)
throws PyException
{
PythonInterpreter interp =
new PythonInterpreter();
interp.exec("import Test2app");
}
}
This happens:
Exception in thread "main" Traceback (innermost last):
File "<string>", line 1, in ?
File "/webhome/servlets/gkt/WEB-INF/classes/./Test2app.py", line 10, in ?
java.lang.ExceptionInInitializerError: java.lang.NullPointerException
at org.python.modules.os.<clinit>(os.java:11)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at
org.python.core.SyspathJavaLoader.loadClass(SyspathJavaLoader.java:57)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.python.core.Py.findClassEx(Py.java:607)
at org.python.core.imp.loadBuiltin(imp.java:198)
at org.python.core.imp.load(imp.java:354)
at org.python.core.imp.load(imp.java:376)
at org.python.core.imp.importName(imp.java:447)
at org.python.core.imp.importName(imp.java:509)
at org.python.core.ImportFunction.load(__builtin__.java:967)
at org.python.core.ImportFunction.__call__(__builtin__.java:961)
at org.python.core.PyObject.__call__(PyObject.java:250)
at org.python.core.__builtin__.__import__(__builtin__.java:921)
at org.python.core.imp.importOne(imp.java:518)
at
Test2app$py.f$0(/webhome/servlets/gkt/WEB-INF/classes/./Test2app.py)
at
Test2app$py.call_function(/webhome/servlets/gkt/WEB-INF/classes/./Test2app.py)
at org.python.core.PyTableCode.call(PyTableCode.java:155)
at org.python.core.imp.createFromCode(imp.java:157)
at org.python.core.imp.createFromPyClass(imp.java:74)
at org.python.core.imp.loadFromPath(imp.java:310)
at org.python.core.imp.loadFromPath(imp.java:252)
at org.python.core.imp.load(imp.java:357)
at org.python.core.imp.load(imp.java:376)
at org.python.core.imp.importName(imp.java:447)
at org.python.core.imp.importName(imp.java:509)
at org.python.core.ImportFunction.load(__builtin__.java:967)
at org.python.core.ImportFunction.__call__(__builtin__.java:961)
at org.python.core.PyObject.__call__(PyObject.java:250)
at org.python.core.__builtin__.__import__(__builtin__.java:921)
at org.python.core.imp.importOne(imp.java:518)
at org.python.pycode._pyx0.f$0(<string>)
at org.python.pycode._pyx0.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:155)
at org.python.core.Py.runCode(Py.java:1055)
at org.python.core.Py.exec(Py.java:1076)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at Test2Run.main(Test2Run.java:11)
java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
Anyone run into this before? There is some failure happening with a class
initializer (in Java).
George
|