Stephen Rossman writes:
...
You mention in your article that you couldn't get the system to read
your properties from the tomcat servlet context - neither could I.

I tried adding a ServletContextPropertyPlaceholder to the application
but my Spring knowledge is pretty poor so I don't know if I was doing
it right. Cocoon stopped working (can't remember the error).
[...

I found quite a bit of strangeness trying to get this done.

My goal was to leave the cocoon webapp servlet alone so it
didn't need to be edited when deploying on any servlet container.
To that end, the SitemapServlet in my cocoon webapp has:

    context-path="file://${webroot}"

Now I want to get webroot defined completely outside the scope
of the servlet.

It works, for example, to define webroot when tomcat is launched
with a java command line expression like:

   -Dwebroot=/var/www/html

An jetty is happy (on Windows) if an operating system environment
variable is defined.

This works, I suppose, because in cocoon the Spring 
PropertyPlaceholderConfigurer
has the searchSystemEnvironment property set to "true." (I don't know that for
sure. I never did find a bean where it gets configured in the cocoon svn trunk.

These are the only two places where I found I could define a variable outside
the scope of the servlet and have it get to the Spring placeholder in my
application context.

But here are some unexpected results which may be bugs in Spring, Jetty,
Tomcat, or my brain.

As you found, both Jetty and Tomcat have the concept of a context.xml file.
On tomcat, (the documentation says) this file can be used to define properties
or environment variables. But I found that these expressions do not get
passed to Spring placeholders:

tomcat/conf/context.xml:

   <Environment
        name="webroot"
        type="java.lang.String"
        value="file:///C:/Program Files/Tomcat 6.0/webapps/cocoon"
   />

And this doesn't work either:

tomcat/conf/context.xml:

   <Parameter
       name="webroot"
       value="file:///C:/Program Files/Tomcat 6.0/webapps/cocoon"
   />

I also tried running this webapp with the RCL. To that end, I tried
adding a definiion for webroot to the rcl.properties:

rcl.properties:
   csparks.com.cocoon22.service%classes-dir=./target/classes
   webroot=file:///windows mess/target/cocoon22-1.0

But this definition never got to the placeholder either.

These are mysteries to me.

I'd like to see your 'trivial' bean that copies values from the context.
But do you think the fact that the context Environment elements are
ignored is a bug in the way tomcat starts up Spring?

Thanks,

-Hugh Sparks


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

Reply via email to