Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  1. Create the webapp directory (you may use any name you want):
    mkdir -p [dspace]/webapps-jython/WEB-INF/lib
    Tip: The jython webapp is just another webapp like the individual DSpace webapps. So while you could put it next to the DSpace webapps into [dspace]/webapps/jython/, it's preferable to choose a different location (e.g. [dspace]/webapps-jython/) because the [dspace]/webapps/ directory is replaced every time you run "ant update" (the old webapps directory will not be deleted, it will be renamed to "webapps-[timestamp]").
  2. Download the latest Jython installer jar (e.g. jython-installer-2.7.1.jar) from (the website was last updated around 2015 [issue2658]; check Maven Central for latest jython version)
    curl -O -J
  3. Get jython.jar and the Lib directory.;
    1. either unzip the installer jar:
      unzip -d [dspace]/lib/ jython-installer-2.7.1.jar jython.jar 'Lib/*'
      unzip -d [dspace]/webapps-jython/WEB-INF/lib/ jython-installer-2.7.1.jar jython.jar 'Lib/*'
    2. or use it to install Jython: 
      java -jar jython-installer-2.7.1.jar --console
      Note: Installation location doesn't matter, this is not necessary for DSpace. You can safely delete it after you retrieve jython.jar and Lib
  4. Associate .py files with Jython's PyServlet

    Code Block


  5. Create a Hello World servlet:

    Code Block
    # -*- coding: utf-8 -*-
    from javax.servlet.http import HttpServlet
    class hello(HttpServlet):
        def doGet(self, request, response):
            self.doPost(request, response)
        def doPost(self, request, response):
            toClient = response.getWriter()
            toClient.println("<h1>Hello World!</h1>")
            toClient.println(u"<p>To make sure utf-8 works, here's a Czech pangram for you:</p><p>Příliš žluťoučký kůň úpěl ďábelské ódy.</p>"

    Access to DSpace classes from Jython

  6. Copy DSpace jars to the jython webapp's lib directory:
    cp -r [dspace]/lib/* [dspace]/webapps-jython/WEB-INF/lib/
  7. Start up DSpace kernel on webapp startup and point it to your DSpace configuration:

    Code Block
        <!-- DSpace Configuration Information -->
        <!-- new ConfigurationService initialization for dspace.dir -->
            <description>The location of the main DSpace configuration file</description>

  8. Define the context in Tomcat's configuration. There are several ways how you can do that, so just use the same way you use for configuring DSpace contexts. The recommended one is to use a context fragment:

    Code Block
    titlesudo vim /etc/tomcat7tomcat8/Catalina/localhost/jython.xml
    <Context docBase="/dspace/webapps-jython" reloadable="true" cachingAllowed="false" />

    A few seconds after you save the file, Tomcat will notice it and load the "jython" context.


  1. Copy the .jar to /dspace/webapps-jython/WEB-INF/lib/
  2. Reload the context
    sudo touch /etc/tomcat7tomcat8/Catalina/localhost/jython.xml