On Mon, 12 Nov 2001, Lieyong Fu wrote:
> I'm embeding Jython script into my Java class. The interesting thing is that
> my Java class "live in" the context of BEA Weblogic Server Domain. To be
> specific, My classes are Session EJB beans. I.e. I'm embeding Jython from
> Session EJB beans.
> The problem I'm having is that I can not import Javax Classes like
> Javax.naming.NamingException in the Jython which would have been OK had I
> embeded the same Jython from a stand alone Java class (run the java class
> from java command and give it a proper CLASSPATH)
> I think the problem is that I need to programatically set the CLASSPATH for
> Jython but I don't know yet how. Any help will be highly appreciated.
Maybe try sys.add_package("javax.naming"), (if you haven't already).
//before trying to import a class in javax.naming, do this
PySystemState sys = Py.getSystemState();
The org.python.util.PyServlet.java file that comes with Jython is a good
example of using sys.add_package as well as sys.add_extdir and
sys.add_classdir. You may be seeing something similar to what required
PyServlet to use the add_package calls.