PDA

View Full Version : Configuring Tomcat with fragments


mburbidg
May 22nd, 2008, 07:39 PM
The documentation says:


In addition to the Catalina artifacts, the repository contains also a Tomcat activator (that works with both 5.5.x and 6.0.x versions) named catalina.osgi.start. The activator understands Tomcat XML configuration and contains a default, minimal setup that starts the server on localhost, port 8080. This behaviour can be customized by placing the desired configuration (which will override the default one) under conf/server.xml location (following the Tomcat folder layout) in a fragment attached to the Tomcat activator.


By this I would assume that I could provide my own default-server.xml in a fragment associated with the startup bundle. But this appendix also states concerning fragments:


A fragment cannot have its own class loader nor a bundle activator and cannot override the information already present in the host. In short, through fragments, bundles can be extender with resources, classes and even manifest entries.


By this I would assume that I can't provide an alternate version of either default-server.xml or embedded-server-defaults.properties.

I can't find any description on the tomcat website about the default-server.xml file. Is it read if there is not a server.xml file and so the way I override it is with a server.xml file? Similarly with the embedded-server-defaults.properties file.

Thanks,
Michael-

mburbidg
May 22nd, 2008, 08:22 PM
Yes I can override these two files by specifying the same files in my fragment whose name has the "default" removed.

No I'm wondering what to put in my embedded-server.properties file for the home field. I understand it to be the directory where catalina will be started and so it will look for things like the webapps directory inside this directory. I don't really want to hardcode this. I would like it relative to the bundle. Can I do that?

Costin Leau
May 24th, 2008, 05:54 AM
Michael, the default files are not meant to be overriden literally - the activator will first look for the custom user file and then, if none is found, fall back to the default one.
This is also mentioned in the ref docs:
http://static.springframework.org/osgi/docs/current/reference/html/web.html#web:osgi-artifacts:containers


can be customized by placing the desired configuration (which will override the default one) under conf/server.xml location (following the Tomcat folder layout) in a fragment attached to the Tomcat activator.


As for the properties, don't worry about them. They will be removed in the future as the XML is the preferred way of configuring Tomcat.

As for the default directory - don't put anything in there. The wars have to deployed as bundles and Spring-DM will pick them up and install them. Rather then provide an pickup directory, Spring-DM uses the OSGi to pick wars installed as bundles.