Semantic web application with Jena toolset, Maven and Jython in Eclipse

I expect you arrived here because you would like to use Python (Jython) to create a web application running on say Tomcat that also utilizes the Jena Semantic Web Framework? Maybe you also would like to add Maven to this mix?

You’ve come to the right place then!

This is not an in-depth tutorial. I will only point to good sources, talk about my experiences And assure you that such a Maven/Jython/Jena/Tomcat webapp can be done!

Resources (in the order I expect you would need them):

  1. Download Eclipse, I can tell you I used the Eclipse IDE for Java EE Developers.
  2. Setting up Maven in Eclipse (Good video tutorial)
  3. Webcached step-by-step guide, for creating a Jython web application that uses Maven and runs on a Tomcat server. Don’t know how long this will stay cached by Google, so I will include a text-export here. The author of that page has also released the sample project under an Apache 2.0 license, so you do have the option to just build upon his work directly.
  4. Install Git for Windows. The tutorial mentioned above will ask you to perform certain commands inside the project you’re creating. If you’re on Windows that might be a hazzle to navigate to the relevant folder with the cmd. Having installed Git you can instead right click the folder and select “Git Bash here” to fire up a command-line window that’s navigated to be exactly where you need to be before typing in the Maven commands.
  5. How-to change WTP version in Maven. The tutorial prompts you to do that, without saying how.
  6. Example: Using Jena with Jython. Just shows how you can interact with the Jena toolset. I modified that code just a little bit in order to make it into a servlet: See what I did (Gist).

There’s also an alternative

You could also use the Play Web Framework (excellent video introduction there), which is Java-based and supports rapid development. In our semantic web project we wanted to find an easy way to create a web application that uses the Jena Toolset. Frameworks like the Spring Web Framework seemed much to heavy for our purposes, so we we’re attracted to the idea of creating a Jython/Jena combo. After a lot of researching/googling/headscratching I made it work. (And felt quite proud for doing so.) Naturally, it didn’t take long before someone introduced me to the Play Web Framework. It seems awesome, and we might go with that instead. Nevertheless, there might be instances where you would like to use Jena in a pythonic way on a web server.

Cheers!