From: Robert W. B. <rb...@di...> - 2001-11-13 03:05:16
|
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. > Thanks, > Lieyong Maybe try sys.add_package("javax.naming"), (if you haven't already). //import this import org.python.core.PySystemState; //before trying to import a class in javax.naming, do this PySystemState sys = Py.getSystemState(); sys.add_package("javax.naming"); //Then... interp.exec("import javax.naming.NamingException") 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. -robert |