Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jython use in a web-app

Roger Studner
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following piece of code:
public static void executeJob(Job job) throws Exception {
PythonInterpreter pyi = new PythonInterpreter();
pyi.set("job", job);pyi.execfile(EngineUtil.class.getResourceAsStream(""));

The 'execution script' starts with that line:
from import *

When I run it from the command line in a java app with a main (with all relevant stuff on the classpath) everything works.

When I try to run the exact same piece of code inside a web-app (therefore all class files and jars are deployed to /project/WEB-INF (jython.jar in lib, classes in WEB-INF/classes of course).

I got the error:
Traceback (innermost last):
File "<iostream>", line 2, in ?
ImportError: no module named com

at org.python.core.Py.ImportError(
at org.python.core.imp.import_first(
at org.python.core.imp.import_name(
at org.python.core.imp.importName(
at org.python.core.ImportFunction.load(
at org.python.core.ImportFunction.__call__(
at org.python.core.PyObject.__cal

etc etc.

Why, in a web-app deployment, can the python interpreter not find any of the classes to import?

Any ideas?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic