• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jython use in a web-app

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("JobRunner.py"));
pyi.execfile(EngineUtil.class.getResourceAsStream("StepFactory.py"));
pyi.exec(job.getExecutionScript());
}

The 'execution script' starts with that line:
from com.company.blah.blah 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(Py.java:193)
at org.python.core.imp.import_first(imp.java:523)
at org.python.core.imp.import_name(imp.java:592)
at org.python.core.imp.importName(imp.java:625)
at org.python.core.ImportFunction.load(__builtin__.java:1006)
at org.python.core.ImportFunction.__call__(__builtin__.java:999)
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?

Thanks,
Roger
oreoferret@gmail.com
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic