Thanks, you made my day complete :) It worked like a charm. I installed again with the standalone option and then deployed to maven repo, and now it all works soooooo nice :) Thanks.

On 2010-08-25 20.46, "ext David Handy" <> wrote:

Did you make sure that you deployed the “stand-alone” jython.jar into Maven, instead of the standard jython.jar that is installed by default? The stand-alone jython.jar includes the standard library, including the re module, in the jar file, whereas the standard jython.jar gets the standard Python library from an external directory.
I don’t know why this would affect Maven but not your framework. Perhaps your framework was using the standard jython.jar from its installed location, and therefore jython.jar was able to find the standard library directory relative to its own location. That would not work if you ever moved jython.jar somewhere else.
David H

From: Peter Lauri []
Sent: Wednesday, August 25, 2010 12:18 PM
Subject: [Jython-users] Problems when running jython in ScriptEngine with Maven2


We have deployed the jython 2.5.1 jar file that we have created at installation. We have a small framework where the users can write jython code. However, when I was just adding the jython.jar to build path as external library all was working well.

After that we added that jar file to our local maven repository, then we start to get problems. It cannot find the “re” package. Here is the complete error output. It seems like I need to specify where the modules are located, but how to do that for the script engine?

Any help or hint would be happily received.



2010-08-25 19:09:55,223 2072 ERROR (main) PythonParser.parse:91 - Error while running the code:
# for regular expressions
import re

match =‘a’, “qwedas”)

javax.script.ScriptException: ImportError: No module named re in <script> at line number 2
    at org.python.jsr223.PyScriptEngine.scriptException(
    at org.python.jsr223.PyScriptEngine.eval(
    at org.python.jsr223.PyScriptEngine.eval(
    at javax.script.AbstractScriptEngine.eval(
    at com.nsn.pc.rebus.parser.impl.python.PythonParser.parse(
    at com.nsn.pc.rebus.parser.impl.python.PythonParserTest.simple(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.ParentRunner$
    at org.junit.runners.ParentRunner$1.schedule(
    at org.junit.runners.ParentRunner.runChildren(
    at org.junit.runners.ParentRunner.access$000(
    at org.junit.runners.ParentRunner$2.evaluate(
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
    at org.apache.maven.surefire.booter.SurefireBooter.main(
Caused by: Traceback (most recent call last):
  File "<script>", line 2, in <module>
ImportError: No module named re

    at org.python.core.PyException.fillInStackTrace(
    at java.lang.Throwable.<init>(
    at java.lang.Exception.<init>(
    at java.lang.RuntimeException.<init>(
    at org.python.core.PyException.<init>(
    at org.python.core.PyException.<init>(
    at org.python.core.PyException.<init>(
    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.__call__(
    at org.python.core.PyObject.__call__(
    at org.python.core.__builtin__.__import__(
    at org.python.core.__builtin__.__import__(
    at org.python.core.imp.importOne(
    at org.python.pycode._pyx0.f$0(<script>:6)
    at org.python.pycode._pyx0.call_function(<script>)
    at org.python.core.Py.runCode(
    at org.python.core.__builtin__.eval(
    at org.python.util.PythonInterpreter.eval(
    at org.python.jsr223.PyScriptEngine.eval(
    ... 30 more