Skip to content

Installation with Karaf

yuchangyuan edited this page Jan 1, 2012 · 4 revisions

Original instructions by Changyuan Yu (see: https://lists.ifi.uzh.ch/pipermail/attempto/2011-December/000832.html), edited by Kaarel Kaljurand.

Tested on Ubuntu 11.04, using ape.exe via the APESocket and APEWebservice interfaces (in order to use APELocal, one needs to reference SWI-Prolog's jpl.jar somehow. Don't know how yet.)

First time setup:

  1. Download Apache Karaf from http://karaf.apache.org/

  2. Unzip, untar

  3. Run bin/karaf resulting in a prompt karaf@root>

  4. Install the war feature by features:install war (at the Karaf prompt)

  5. Deploy AceWiki by copying acewiki.war into Karaf's deploy-directory, e.g.

> $ ant createwebapps

> $ cp acewiki.war ${HOME}/myapps/apache-karaf-2.2.4/deploy/
  1. list (at the Karaf prompt) will show all the installed bundles, among them AceWiki

  2. AceWiki is now live at http://localhost:8181/acewiki/acewiki/

To update AceWiki in the running instance of Karaf just copy a new version of the AceWiki war-file into the Karaf deploy-directory.

TODO:

  • How to make Karaf access external jars (e.g. jpl.jar which is required by APELocal)?

Some comments about how to make AceWiki be able to access other classes.

Karaf is an OSGi container, any method that work with OSGi container should work with Karaf. So there're two methods:

  1. Embed the jar into the war directly.

  2. Make the dependence(e.g. jpl.jar) as an OGSi bundle, and import the necessary classes in acewiki.war

The first method is the current way we handle other dependent jars, just copy to "WEB-INF/lib" in the war file, and make necessary modifications in meta-inf/manifest.mf. The later one is a more elegant way to handle class dependence which is prefered for OSGi environment. The dependent jar is a bundle in OSGi environment, export some public classes, and other bundles can import those classes(declared in meta-inf/manifest.mf). To make a jar compatible with OSGi, see http://blog.springsource.com/2008/02/18/creating-osgi-bundles/. If we do not need special version and class import/export control, we can just put the jar into deploy folder of Karaf(NOTE: this is a Karaf feature, not a standard OSGi feature).

For jpl.jar, which use jni to interface with prolog, should be specially handled. There're two ways to make jni work with OSGi:

  1. Set java.library.path when start Karaf(set JAVA_OPTS enviroment when start karaf), or copy all necessary dynamic libraries to system path.

  2. Embed dynamic library into the bundle directly. A quick google search lead to this page: http://robertvarttinen.blogspot.com/2008/12/bundle-nativecode-in-osgi-manifest.html