From: Russo, Tom <tom@st...> - 2001-07-19 20:27:27
Thanks, that's very helpful. However, how about this: when I change the
"import socket" line to:
Traceback (innermost last):
File "", line 1, in ?
I assume that this is a different problem? Is there a fix for this one?
From: bckfnn@... [mailto:bckfnn@...]
Sent: Thursday, July 19, 2001 3:50 PM
Cc: Russo, Tom
Subject: Re: [Jython-users] jython.jar useable when not on classpath?
>I'm having some trouble using jython from within a jsp page.
Take a look at how PyServlet.java attempts so solve the problem
The lines of special interest is:
sys.add_classdir(rootPath + "WEB-INF" +
File.separator + "classes");
sys.add_extdir(rootPath + "WEB-INF" +
File.separator + "lib");
It allows *package* import from the WEB-INF/lib and WEB-INF/classes
directories. Note that the problem you are seeing have nothing to do
with class loading. The problem occurs because jython needs to know if
the package "org.python" is (part of) a valid java package.
>Tomcat 3.2.2, jython 2.0, ...
Unfortunately the add_classdir and add_extdir was added in jython-2.1a1.
>I guess the ultimate question is: is it possible to use jython.jar when
>not on the classpath?
You can always tell jython about the java packages that is available
>Thanks, that's very helpful. However, how about this: when I change the
>"import socket" line to:
>Traceback (innermost last):
> File "", line 1, in ?
>I assume that this is a different problem? Is there a fix for this one?
Yes, it is fixed in jython-2.1a1.
As a workaround you can assign a value to sys.prefix before importing
"os". The exception is thrown because sys.prefix is null.