HOWTO Xindice 1.1b and Cocoon 2
by Barzilai Spinak barspi@internet.com.uy
April 6th, 2003
Disclaimer: This How-To reflects only my experience trying to make Xindice 1.1b work with Cocoon 2.0.4 within the environment mentioned below. I cannot guarantee your results with different versions of the packages. Consider that, as of this writing, Xindice 1.1b is just that... a project in a beta state. I'm not involved in the development of neither Xindice, nor Cocoon. In fact, I'm pretty much a newbie at both so I may be doing some things wrong, or in a way that is different from what the developers intend or consider "best practices".
All in all, I'm writing this because I had a problem to solve and could not find a single tutorial explaining the subject. Then, many people on the Xindice list asked me to post my solution... so here it is.
Have fun!!
Tested platform:
I will explain everything according to my platform but that doesn't mean it won't work under Windows or with a different Java version, etc. Just make adjustments to fit your setup.
Assumptions:
I asssume that the following is true:
You have installed J2SE and exported the JAVA_HOME variable.
You have installed Tomcat 4 and have exported the TOMCAT_HOME variable. (It normally starts on port 8080, so if you go to http://yourhost:8080 you will get your local Tomcat page)
You have installed the Cocoon "war" file under $TOMCAT_HOME/webapps and it has been correctly deployed by Tomcat, expanding it and creating the cocoon directory under webapps . (If you go to http://yourhost:8080/cocoon you should get the Cocoon main page).
CVS checkout
Now we need to get the complete CVS repository for Xindice 1.1b. The reason for this is that, as of this writing, none of the 3 pre-built .zip or .tar.gz distributions (jar, war, src) are complete. In particular, you won't be able to build Xindice from the src distribution because it's missing the config directory and maybe other stuff...
So go ahead, make a new directory, and checkout the whole thing as explained here (the module name is xml-xindice )
Building
Now everything has been downloaded to a directory called xml-xindice. Rename the file build.properties.sample to build.properties and edit it so the tomcat.home property is set to whatever your TOMCAT_HOME is.
(This step I'm not sure whether it's necessary but it didn't hurt to do it. Please comment :-)
Let's build it: ./build.sh
(The CVS checkout already includes a version of Ant but if you have your own installed then you can just use the command ant and it will build from the build.xml file)
If everything went OK, you have compiled all the source and samples, and generated the war and jar releases which are in the dist directory.
Note: Since we're working with a beta version, the packages may not compile because someone is working on them. As a matter of fact, everything I explained here worked last night but as I write this someone has been modifying code that has been untouched for a few months and now it won't build!!! Let's hope this is solved promptly :-)
The new Xindice
In version 1.0, Xindice comes as an independent service listening on port 4080. It also has a couple of command line tools called xindice and xindiceadmin which, for the most part, overlap in their functionality.
In version 1.1, Xindice has become a servlet, or webapp, which runs under a servlet engine like Tomcat or JBoss. There's also a command line tool called xindice which does the job of the two old command line tools.
So, in my understanding, there are two parts to a Xindice installation: war webapp, and command-line administration tool.
Installing the Xindice ''war''
Now we're going to install the Xindice webapp under Tomcat. It comes in a war file which was generated by the building step and put into the dist directory of the CVS checkout. It will probably be called xindice-1.1b.war but it needs to be renamed to Xindice.war (that's a capital X) because that's what Xindice expects to be called...
Copy the newly renamed dist/{ { { Xindice.war } } } to $TOMCAT_HOME/webapps
Start Tomcat, and it should expand and deploy Xindice.war into a directory called $TOMCAT_HOME/webapps/Xindice
Test that everything is working by browsing to http://yourhost:8080/Xindice We should get the THIS IS AN UGLY DEBUG TOOL! page.
Installing the Xindice command line tool
For this, I used my personal preferences, as I did not find guildelines as to what the best practices are. I decided to install the command line tool and libraries under /usr/java/xindice and make that directory my XINDICE_HOME. Also I wanted to share the database root (/db) with the webapps installation.
- Create /usr/java/xindice (or the directory of your preference)
- Set and export XINDICE_HOME appropriately and include it in your shell scripts and profiles
- From your CVS checkout, copy the following stucture into your new $XINDICE_HOME
bin/* (start-up scripts)
dist/* (war and jar distributions)
java/lib/* (lots of library jars needed by Xindice)
config/* (many xml configuration files needed by Xindice)
- In order to share the same document database between the command line tool and the webapp you may want to make a symbolic link:
ln -s $TOMCAT_HOME/webapps/{ { { Xindice } } }/WEB_INF/db $XINDICE_HOME/db
- Make sure you include $XINDICE_HOME/bin in your path!!
Now you can try the command xindice lc -c /db to see if everything works. You should get a listing of collections under /db (usually just system since you haven't added anything yet)
If this doesn't work then use the full path for the -c switch e.g.; xindice lc -c xmldb:xindice://localhost:8080/db
Preparing Cocoon
In $TOMCAT_HOME/webapps/cocoon/WEB_INF/lib copy the following files:
$XINDICE_HOME/dist/xindice-1.1b.jar
$XINDICE_HOME/java/lib/xml*.jar
- Delete the following files from that same directory since we have just provided newer versions:
xindice.jar (this is if you already had Xindice 1.0 running under Cocoon)
xml-apis.jar
xmldb-api-20011111.jar
Now we have to provide a protocol handler for Cocoon. Edit the file $TOMCAT_HOME/webapps/cocoon/WEB_INF/cocoon.xconf and look for the <source-handler> tag. If you had been using Cocoon with Xindice 1.0 then you probably have a section that says:
<protocol class="org.apache.cocoon.components.source.XMLDBSourceFactory" name="xmldb">
<!-- Xindice driver -->
<driver class="org.apache.xindice.client.xmldb.DatabaseImpl" type="xindice"/>
<!-- Add here other XML:DB compliant databases drivers -->
</protocol> If not, just add that new protocol inside the <source-handler> and </source-handler> tags.
Before, in your Cocoon sitemap you used source URI's that looked like this:
xmldb:xindice://localhost:4080/db/#{ { { ["MyXPathQuery"] } } }
Now you should change them to the following:
xmldb:xindice://localhost:8080/db/#{ { { ["MyXPathQuery"] } } }