I have successfully managed to set a (not predefined) variable in catalina.properties by adding the line dbconf=mydb. When I call System.getProperties in the code of the web application, this variable appears. However, I would like to access this variable in context.xml inside the web application. More precisely, it should be used in the definition of a Realm, such as
<Realm className="org.apache.catalina.realm.JDBCRealm" driverName="org.postgresql.Driver" connectionURL="jdbc:postgresql://myserver:5432/${dbconf}" connectionName="xxx" connectionPassword="yyy" userTable="users" userRoleTable="roles" userNameCol="name" userCredCol="pw" roleNameCol="role" digest="MD5" /> The syntax ${dbconf}, which I found in several forums on the net, did not work. Any hint? Bill Barker-2 wrote: > > As Konstantin has already pointed out, any value that you can get from > System.getProperty("...") will be used for substitution. And to expand on > Rainer's comment, these are available for substitution in web.xml as well. > This is a Tomcat-specific feature, so limits your ability to port to other > containers. There is currently no support for ${ENV.xxx}, it needs to be > a > Java property, not just an env variable. > > > "Maxim Veksler" <maxim.veks...@gmail.com> wrote in message > news:b400c69a0809280848k4c588fa5v9353cfe1819f9...@mail.gmail.com... >> On Sun, Sep 28, 2008 at 2:37 PM, Rainer Jung <rainer.j...@kippdata.de> >> wrote: >>> Maxim Veksler schrieb: >>>> Hello list, >>>> >>>> I'm looking for a way to make my tomcat configuration more dynamic >>>> without resorting to editing xm files. I considering doing this by >>>> using parameter substitution. >>>> I've seen from the SSL guide that tomcat will accept configurations >>>> like """${user.home}""". >>>> >>>> Is there a list, or a known set of these options that tomcat will >>>> read? Getting at least a reference to the cataline_home will be very >>>> helpful. >>>> >>>> >>>> p.s. >>>> I know from ant files that you can do ${env.SOMEVAL} to get the >>>> environment, sadly this does not work here. Is there an equivalent >>>> alternative ? >>> >>> The answer depends on the exact version you are using. All version 5.5 >>> and 6 Tomcats and recent version 4.1 Tomcat supports resolving >>> ${somevariable} in server.xml by looking at system properties >>> automatically. >>> >>> Some properties are set during Tomcat startup, like catalina.home and >>> catalina.base. Others you can set yourself by either adding to the >>> commandline "-Dsomevariable=somevalue" or adding to the end of >>> conf/catalina.properties. >>> >>> Not all config files aloow this. I think catalina.properties itself does >>> only allow for catalina.home and catalina.base and not general system >>> properties, log4j.properties allows general system properties, I'm not >>> sure about context.xml and web.xml at the moment (you could try). >>> >>> Be careful: system properties work, environment variables not. System >>> properties are often seen as a java equivalent of environment variables, >>> although those exist in java too. >>> >>> A common practise in a farms would be, to determine parts of the ports >>> to bind to in a startup script and to set them in server.xml by using >>> system properties, so the server.xml file in the whole farm can be kept >>> identical. >>> >> >> Hello Rainer, >> >> Thank you for the excellent pointers. >> >> >> Are you perhaps familiar with a programmatic / configurable method to >> output putting the full list of properties recognized by tomcat during >> Catalina start up ? >> >> >> Thank you, >> Maxim. >> >>> Regards, >>> >>> Rainer >>> >>> --------------------------------------------------------------------- >>> To start a new topic, e-mail: users@tomcat.apache.org >>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >>> For additional commands, e-mail: users-h...@tomcat.apache.org >>> >>> >> >> >> >> -- >> Cheers, >> Maxim Veksler >> >> "Free as in Freedom" - Do u GNU ? >> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> > > > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > > -- View this message in context: http://old.nabble.com/%24%7Buser.home%7D-and-other-server.xml-tags-accepted-by-Tomcat--tp19710754p31407328.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org