[Web-SIG] Modjy and external packages.

Alan Kennedy py-web-sig at xhaus.com
Wed Oct 6 16:56:30 CEST 2004


[Alan Kennedy]
 >>When referencing external jars in modjy applications, it is not
 >>sufficient to place the jar on the classpath, or to place it in the
 >>WEB-INF/lib directory.

[Paul Boddie]
 > Really? I know that Java Servlet deployment issues are infuriating
 > enough as
 > it is, but all I've ever needed to do with JythonServlet (which forms
 > the
 > basis of WebStack's Java/Jython support) is to make sure that relevant
 > libraries reside in the WEB-INF/lib directory.

That only works because the current org.python.util.PyServlet class 
already adds the relevant packages for you behind the scenes. Take a 
look at the source for the PyServlet.java file

http://cvs.sourceforge.net/viewcvs.py/jython/jython/org/python/util/PyServlet.java?rev=1.16&view=markup

The following are the relevant lines

/* ------------------------------------- */
public class PyServlet extends HttpServlet
     {
     /* ....... */

     public void init()
         {
         /* ....... */
         PySystemState sys = Py.getSystemState();
         sys.add_package("javax.servlet");
         sys.add_package("javax.servlet.http");
         sys.add_package("javax.servlet.jsp");
         sys.add_package("javax.servlet.jsp.tagext");
         sys.add_classdir(rootPath + "WEB-INF" +
             File.separator + "classes");
         sys.add_extdir(rootPath + "WEB-INF" + File.separator + "lib",
             true);
         /* ....... */
         }
     }
/* ------------------------------------- */

Regards,

Alan.


More information about the Web-SIG mailing list