On Monday 25 October 2004 18:52, Peter Rossbach wrote:

> I think you can used ${catalina.base} or other system env variables
> inside server.xml and context.xml
> for an absolute path information. Only problem with this handling is,
> don't save your server.xml oder context.xml
> with the admin application.

Ah, good to know! I was unaware that Tomcat substitute properties in 
context.xml. I dumped the properties in my servlet (an axis-based web 
service, actually) and there doesn't seem to be a suitable property 
available. But as I'm using Spring and Log4j anyway, I noticed that

org.springframework.web.util.Log4jWebConfigurer in conjunction with
org.springframework.web.util.Log4jConfigListener

sets an appropriate property. It needs some declarations in web.xml:

  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>mywebservice.root</param-value>
  </context-param>

  <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
  </context-param>

Then, in context.xml

  <Context path="/mywebservice" 
docBase="/home/michael/workspace/mywebservice/build">
    <Resource name="jdbc/verzeichnisdb" auth="Container"
     type="javax.sql.DataSource" username="sa" password=""
     driverClassName="org.hsqldb.jdbcDriver"
     url="jdbc:hsqldb:file:
${mywebservice.root}/WEB-INF/db/verzeichnisdb;ifexists=true"
     maxActive="3" maxIdle="2"/>
  </Context>

It's not pretty, rather fragile, really, as it depends on the right 
order of evaluation. The url attribute must be evaluated after 
mywebservice.root is already set.


> Tipp: use a db resource path outside your application, than deployer
> can delete all
> files without you lose the data! ;-)

Thanks for reminding me. In this case it's okay to lose the data as it's 
read-only reference data.

Michael

-- 
Michael Schuerig              The usual excuse for our most unspeakable
mailto:[EMAIL PROTECTED]      public acts is that they are necessary.
http://www.schuerig.de/michael/                      --Judith N. Shklar

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to