|
From: Brian Z. <bri...@ya...> - 2001-02-13 06:07:43
|
Hi Finn, ----- Original Message ----- From: "Finn Bock" <bc...@wo...> To: <jyt...@li...> Sent: Monday, February 12, 2001 1:37 PM Subject: Re: [Jython-dev] WEB-INF/classes & WEB-INF/lib/*.jar inaccessible in jython servlet > On Mon, 12 Feb 2001 12:08:30 -0800, you wrote: > > >These classes are accessible from java servlet and JSP pages, but not > >from jython servlet. The workaround would be to include those in > >CLASSPATH of tomcat startup script, but... you know. > > I have not yet look at this in depth, but I think the classes from lib & > classes are available as classes, but not as jython package namespaces. > You can test this by trying to load a class from withon the .py file > with java.lang.Class.forName(). I guess this should work, but the normal > jython import does not work. > Unfortunately this (try load a <context>/WEB-INF/classes class from jython servlet with java.lang.Class.forName()) does not work. What I'm trying to do actually is putting XMLC (see http://xmlc.enhydra.org) compiled pages inside <context>. From within a jython servlet, "java.class.path" System property value does not include <context>/WEB-INF/classes at all. So basically jython servlet has no idea where to get these classes. Two observations, if I have testpkg.TestClass under <context>/WEB-INF/classes: 1. I happen to place org.python.util.PyServlet under tomcat_home/classes, if I add try { Class.forName("testpkg.TestClass").newInstance(); } catch (Exception ex) { System.err.println(e.toString()); } to PyServlet.java, class loading fails. 2. If I add the above code to a servlet within the same <context>, it loads okay. Which is reasonable, but also suggests that servlet class loading does something special when within a <context>. PyServlet need to borrow the same logic. I didn't test JSP, but I believe it should be the same as servlet. /Brian > As a temporary workaround you can add the java packages to the jython > package manager yourself with add_package. > > sys.add_package("testpackage") > from testpackage import TestClass > > >Anyway, enough complains. > > > >I take a brief look at tomcat 3.2 source code at > > > > :pserver:an...@ja...:/home/cvspublic/jakarta-tomcat > > /src/share/org/apache/tomcat > > > >context/LoaderInterceptor.java seems to be where it adds WEB-INF/classes > >and WEB-INF/lib/*.jar to the classloader class repositories. > > > >Can we do similar things in PyServlet.java ? > > It should be possible to force the jython package manager to search > these two wellknown places for java classes and packages. Perhaps by > setting python.packages.paths and python.packages.directories. Perhaps > by calling the package manager directly. More on later. > > regards, > finn > > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-dev > |