Here's how I've successfully started Xindice embedded in Tomcat.
1.) I copied the entire Xindice distribution (after building) to the following directory.
/var/tomcat/webapps/MyApp/WEB-INF/Xindice
2.) I created a servlet with the following code:
/** Initializes the servlet.
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
if(init){
try{
System.out.println();
System.out.println(Title+" "+Version+" ("+Codename+")");
System.out.println();
ServletContext ctx = config.getServletContext();
String path = ctx.getRealPath("");
System.setProperty("openorb.home",path + "/WEB-INF/xindice");
System.setProperty("xindice.home",path + "/WEB-INF/xindice");
File cfg = new File(path, "/WEB-INF/xindice/config/system.xml");
kernel = new org.apache.xindice.server.Kernel(cfg.getAbsolutePath());
}catch(Exception e){
e.printStackTrace();
}
init = false;
}
}
-----
Important note about code, both the xindice.home and openorb.home System.properties need to be set to this xindice directory.
3.) I had to pull the OpenORB.xml and default.xml files from the OpenORB.jar file and place them into
/var/tomcat/webapps/MyApp/WEB-INF/Xindice/config for the Orb to start properly (don't know why).
4.) I removed the HTTP Server section from the system.xml file as I'm using Xindice internally and don't need the ior to show to the world.
5.) Tomcat 4.0.X runs as the tomcat user, since its home directory is /var/tomcat/ this is the "directory" that xindice seems to be started from. So in the System.xml file I did the following
changed all paths that look like
./logs/Xindice.log
to
./webapps/MyApp/WEB-INF/Xindice/logs/Xindice.log
-This configuration starts when tomcat is started (add <load-on-startup>1</load-on-startup> to your web.xml servlet entry get it to start on tomcat start). Watch out if you have servlet reloading set to true in your server.xml, as the above code is executed again if the servlet is reloaded by tomcat. I'm planning a more robust startup Based on a Singleton class in the future.
-Mark Diggory
Hi a few weeks ago I played with the possibility to run Xindice embedded. Here is my aproach, if you like: (I learnd from org.apache.xindice.server.Xindice and org.apache.xindice.server.Kernel)
make sure your CLASSPATH contains following jars and the dot: openorb-1.2.0.jar:xalan-2.0.1.jar:xindice.jar:xerces.jar:.
compile it, using: javac runXindice.java
copy the dir $XINDICE_HOME/config to your actual directory, create the dirs 'docs' and 'logs' and set the env-variable 'xindice.home' to the location where your Xindice home is and then start the runXindice-class:
java -Dxindice.home="/home/goetzger/work/java/runXindice" runXindice
If you want access to your previously created and filled database copy the db directory to your actual working directory as well before starting Xindice.
The code is ocated in the attachment. Have fun
regards
Heinrich -- http://www.xmlBlaster.org
On Fri, 22 Feb 2002, Mark A. Richman wrote:
I haven't quite figured out how to do this. Simply, I'd like to directly access a collection without having to connect to a server process. This way, I can "embed" Xindice into my application. I expect this behavior to be analogous to HypersonicSQL/HSQDB's embedded mode, where there is no "server", but the database can be interacted with by simply referencing the jar file in the classpath.
Thanks, Mark
-----Original Message----- From: Kimbro Staken [mailto:[EMAIL PROTECTED] Sent: Monday, February 18, 2002 10:37 PM To: [email protected] Subject: Re: Xindice as a servlet?
Yes it is possible, there isn't any documentation on how to do it right now though. I started working on some last week but i barely got started.
There's basically two levels that you can embed at. The entire server framework, which brings all the services and would allow you to continue
using the command line tools. And just the database,which will prevent the command line tools from working.
Take a look at org.apache.xindice.server.Xindice to see how the server is started, and org.apache.xindice.server.services.XindiceService to see how the database it self is started.
On Monday, February 18, 2002, at 06:02 PM, Mark A. Richman wrote:
Is there anyway to run Xindice from within a web server, say Tomcat, instead of as its own standalone server? I'd like to be able to handle
client calls via a servlet, so I can incorporate Xindice into my own apps.
Thanks, Mark
Kimbro Staken XML Database Software, Consulting and Writing http://www.xmldatabases.org/
