Re: setenv.sh - how to set system properties to values containing spaces
Thanks again Rainer, Your seccond two points were covered in my initial mail containing the test code I am pretty sure that the issue is with the shell, and have been using the code below to test all sorts of combinations of values for OPTS - the only way I can get the arg to print on one line is to quote $OPTS when it is expanded, which obviously will not work if there are any other options required in CATALINA_OPTS. exec is not included in my example, as tc 6.0.16 does not include it when it "start"s only when it "run"s. Thanks again, catalina.properties it is. Bap. Adding to what André explains: the following small script shows a working procedure: #!/usr/bin/ksh OPTS=-DXXX="a b" # or alternatively # OPTS="-DXXX=a b" exec /usr/local/jdk1.6.0/bin/java "$OPTS" myprog What is important here: - the original variable including the system property is used on the commandline, no intermediate expansion or adding other tokens to the same variable - there is only one system property in the variable. You cann add the non-problematic ones to the standard variable, or if there are multiple properties with spaces, use multiple aditional variables. - The quotes aroung $OPTS in the line starting java. They are used, so that the shell passes the whole of $OPTS as one argument to the java process. The exec is only there, because it is done like that in the standard script. Regards, Rainer - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
Hi André, Now I understand the issue regarding the -jdpa option. I had not even considerred that one - if set, then CATALINA_OPTS would require 2 levels of escape, and, if not set, just one! I have only been looking at the "start" block as called by startup.sh without using -security exec (whatever) (whatever_java_opts) -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl (whatever_follows) which is pretty much what you are seeing, right ? No, if I place echo at the start of the line that starts tomcat ("start" block, no -security) what I see is: /usr/java/default/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/opt/bh-adws/conf/logging.properties -Xms128m -Xmx256m -Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\" -Dcom.sun.jndi.ldap.connect.pool.timeout=1 -Djava.endorsed.dirs=/opt/bh-adws/endorsed -classpath :/opt/bh-adws/bin/bootstrap.jar -Dcatalina.base=/opt/bh-adws -Dcatalina.home=/opt/bh-adws -Djava.io.tmpdir=/opt/bh-adws/temp org.apache.catalina.startup.Bootstrap start using you suggestion below, and /usr/java/default/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/opt/bh-adws/conf/logging.properties -Xms128m -Xmx256m -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" -Dcom.sun.jndi.ldap.connect.pool.timeout=1 -Djava.endorsed.dirs=/opt/bh-adws/endorsed -classpath :/opt/bh-adws/bin/bootstrap.jar -Dcatalina.base=/opt/bh-adws -Dcatalina.home=/opt/bh-adws -Djava.io.tmpdir=/opt/bh-adws/temp org.apache.catalina.startup.Bootstrap start if I use CATALINA_OPTS='-Xms128m -Xmx256m -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" -Dcom.sun.jndi.ldap.connect.pool.timeout=1' as you can see, the quoting looks correct, yet the shell passes through 2 separate arguments for the property first as -Dcom.sun.jndi.ldap.connect.pool.protocol="plain and the seccond as ssl" I think I am going to have to go with Rainer's suggestion of appending to conf/catalina.properties - not very nice, but should work. Thanks for all your help, Bap. As far as system properties go - why does Sun insist on using them for configuration, with no alternatives for configuration within a given scope, not jvm wide? Quoting André Warnier : Sorry, I mistook "CATALINA_OPTS" for "JAVA_OPTS", but Bap wrote: Hi André, The solution you have suggested just introduces a new variable, but with exactly the same characteristics of the existing CATALINA_OPTS variable (unless I am missing something.) Say that, originally in setenv.sh, you set CATALINA_OPTS as follows (in one single line) : CATALINA_OPTS='-Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl"' Then, in catalina.sh, a line such as the following : CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" would make CATALINA_OPTS now be : -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" then, at the next invocation, say here : exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS this would be seen as exec (whatever) (whatever_java_opts) -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl (whatever_follows) which is pretty much what you are seeing, right ? Now, what I am trying to tell you is : the CATALINA_OPTS variable is used several times in the catalina.sh script, in a way that may make it difficult to determine how many times it is being so "interpolated" into itself before being finally used. Each level of such interpolation, will remove one level of quoting. By defining your own variable, and using it just once in catalina.sh, at least you know how many times it is being interpolated (just once), and you can quote it correctly. Now, all this being said, why don't you try this in setenv.sh : CATALINA_OPTS='-Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\"' And all of that being said, whoever decided that the property "com.sun.jndi.ldap.connect.pool.protocol" could be set to a value with embedded spaces ought to be exiled to a remote arctic island. Together with whomever invented file paths with embedded spaces. Together with whomever decided to install Tomcat by default in c:\program files\apache software foundation\. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
On 10.06.2009 15:47, André Warnier wrote: > Sorry, I mistook "CATALINA_OPTS" for "JAVA_OPTS", > but > > Bap wrote: >> Hi André, >> >> The solution you have suggested just introduces a new variable, but >> with exactly the same characteristics of the existing CATALINA_OPTS >> variable (unless I am missing something.) > > Say that, originally in setenv.sh, you set CATALINA_OPTS as follows (in > one single line) : > > CATALINA_OPTS='-Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl"' > > Then, in catalina.sh, a line such as the following : > > CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" > > would make CATALINA_OPTS now be : > > -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" > > then, at the next invocation, say here : > > exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS > > this would be seen as > > exec (whatever) (whatever_java_opts) > -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl (whatever_follows) > > which is pretty much what you are seeing, right ? > > Now, what I am trying to tell you is : > > the CATALINA_OPTS variable is used several times in the catalina.sh > script, in a way that may make it difficult to determine how many times > it is being so "interpolated" into itself before being finally used. > Each level of such interpolation, will remove one level of quoting. > > By defining your own variable, and using it just once in catalina.sh, at > least you know how many times it is being interpolated (just once), and > you can quote it correctly. > > > > Now, all this being said, why don't you try this in setenv.sh : > > CATALINA_OPTS='-Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\"' > > And all of that being said, whoever decided that the property > "com.sun.jndi.ldap.connect.pool.protocol" could be set to a value with > embedded spaces ought to be exiled to a remote arctic island. > Together with whomever invented file paths with embedded spaces. > Together with whomever decided to install Tomcat by default in > c:\program files\apache software foundation\. Adding to what André explains: the following small script shows a working procedure: #!/usr/bin/ksh OPTS=-DXXX="a b" # or alternatively # OPTS="-DXXX=a b" exec /usr/local/jdk1.6.0/bin/java "$OPTS" myprog What is important here: - the original variable including the system property is used on the commandline, no intermediate expansion or adding other tokens to the same variable - there is only one system property in the variable. You cann add the non-problematic ones to the standard variable, or if there are multiple properties with spaces, use multiple aditional variables. - The quotes aroung $OPTS in the line starting java. They are used, so that the shell passes the whole of $OPTS as one argument to the java process. The exec is only there, because it is done like that in the standard script. Regards, Rainer - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
Sorry, I mistook "CATALINA_OPTS" for "JAVA_OPTS", but Bap wrote: Hi André, The solution you have suggested just introduces a new variable, but with exactly the same characteristics of the existing CATALINA_OPTS variable (unless I am missing something.) Say that, originally in setenv.sh, you set CATALINA_OPTS as follows (in one single line) : CATALINA_OPTS='-Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl"' Then, in catalina.sh, a line such as the following : CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" would make CATALINA_OPTS now be : -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" then, at the next invocation, say here : exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS this would be seen as exec (whatever) (whatever_java_opts) -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl (whatever_follows) which is pretty much what you are seeing, right ? Now, what I am trying to tell you is : the CATALINA_OPTS variable is used several times in the catalina.sh script, in a way that may make it difficult to determine how many times it is being so "interpolated" into itself before being finally used. Each level of such interpolation, will remove one level of quoting. By defining your own variable, and using it just once in catalina.sh, at least you know how many times it is being interpolated (just once), and you can quote it correctly. Now, all this being said, why don't you try this in setenv.sh : CATALINA_OPTS='-Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\"' And all of that being said, whoever decided that the property "com.sun.jndi.ldap.connect.pool.protocol" could be set to a value with embedded spaces ought to be exiled to a remote arctic island. Together with whomever invented file paths with embedded spaces. Together with whomever decided to install Tomcat by default in c:\program files\apache software foundation\. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
Hi André, The solution you have suggested just introduces a new variable, but with exactly the same characteristics of the existing CATALINA_OPTS variable (unless I am missing something.) The issue is, that even when the CATALINA_OPTS value looks like it is correctly quoted (echo of CATALINA_OPTS below), when java is invoked, it gets the system property com.sun.jndi.ldap.connect.pool.protocol set to "plain and the next argument is ssl" which it expects to be the class containing main. -Xms128m -Xmx256m -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" -Dcom.sun.jndi.ldap.connect.pool.timeout=1 Thanks for the suggestion, Bap. Quoting André Warnier : Bap wrote: ... Looks very much like the problem from hell, where the number of extra quoting levels depends on the number of times this thing ends up being interpolated. A suggestion, which involves modifying catalina.sh, but maybe with less nefarious effects if it ever gets replaced : - modify catalina.sh such that, in each command-line executing Tomcat and in which $JAVA_OPTS is invoked, you add another $MY_JAVA_OPTS after the $JAVA_OPTS. - then define MY_JAVA_OPTS in setenv.sh, with what you want as additional options, using only 1 level of additional quoting. e.g. exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ becomes exec "$_RUNJAVA" $JAVA_OPTS $MY_JAVA_OPTS $CATALINA_OPTS \ and in setenv.sh : MY_JAVA_OPTS="-Dsomeparam=\"this and that\"" or MY_JAVA_OPTS='-Dsomeparam="this and that"' - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
Bap wrote: ... Looks very much like the problem from hell, where the number of extra quoting levels depends on the number of times this thing ends up being interpolated. A suggestion, which involves modifying catalina.sh, but maybe with less nefarious effects if it ever gets replaced : - modify catalina.sh such that, in each command-line executing Tomcat and in which $JAVA_OPTS is invoked, you add another $MY_JAVA_OPTS after the $JAVA_OPTS. - then define MY_JAVA_OPTS in setenv.sh, with what you want as additional options, using only 1 level of additional quoting. e.g. exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ becomes exec "$_RUNJAVA" $JAVA_OPTS $MY_JAVA_OPTS $CATALINA_OPTS \ and in setenv.sh : MY_JAVA_OPTS="-Dsomeparam=\"this and that\"" or MY_JAVA_OPTS='-Dsomeparam="this and that"' - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
Hi Chris, Thanks for the reply. Unfortunately I had already tried all of those suggestions - and more - before posting. I have just retried the three below, to double check, but unfortunately all with similar results - either looking to run ssl ssl" or ssl' I am pretty sure that the issue is with the shell, and have been using the code below to test all sorts of combinations of values for OPTS - the only way I can get the arg to print on one line is to quote $OPTS when it is expanded, which obviously will not work if there are any other options required in CATALINA_OPTS. Can anyone provide any more suggestions, or am I going to have to modify catalina.sh - I really do not want to do that, for obvious reasons. Again, thanks, in advance, for any help offered, Bap. #!/bin/sh OPTS='"lkjxdf adf"' function echo_args() { echo $1 echo $2 } echo_args $OPTS Quoting Christopher Schultz : -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bap, On 6/9/2009 1:06 PM, Bap wrote: I am trying to set the following system property/value in setenv.sh com.sun.jndi.ldap.connect.pool.protocol="plain ssl" If I enclose the whole CATALINA_OPTS in single quotes, then the value looks fine when echoed, but the catalina.out contains Exception in thread "main" java.lang.NoClassDefFoundError: ssl" The complete contents of setenv.sh is the single line below. CATALINA_OPTS='-Xms128m -Xmx256m -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" -Dcom.sun.jndi.ldap.connect.pool.timeout=1' So, the above echos fine but causes the NoClassDefFoundError? Try any one of the following, which might work: CATALINA_OPTS="-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol=plain\ ssl - -Dcom.sun.jndi.ldap.connect.pool.timeout=1" CATALINA_OPTS='-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol=plain\ ssl - -Dcom.sun.jndi.ldap.connect.pool.timeout=1' CATALINA_OPTS="-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\" - -Dcom.sun.jndi.ldap.connect.pool.timeout=1" These will probably not work: CATALINA_OPTS="-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol='plain ssl' - -Dcom.sun.jndi.ldap.connect.pool.timeout=1" CATALINA_OPTS='-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" - -Dcom.sun.jndi.ldap.connect.pool.timeout=1' I suspect that there is some quoting being done in the catalina.sh script itself which is confusing things. Try looking at the script itself to see where such quoting is being done, and how you might "defeat" it :) - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkousdUACgkQ9CaO5/Lv0PA1QQCfT88n8/vMnkbtiC7wnPgQgdVg 438AmwV8lUADAdBfcWd9VeOZYGJqX2Y6 =zRFk -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: setenv.sh - how to set system properties to values containing spaces
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bap, On 6/9/2009 1:06 PM, Bap wrote: > I am trying to set the following system property/value in setenv.sh > com.sun.jndi.ldap.connect.pool.protocol="plain ssl" > If I enclose the whole CATALINA_OPTS in single quotes, then the value > looks fine when echoed, but the catalina.out contains Exception in > thread "main" java.lang.NoClassDefFoundError: ssl" > The complete contents of setenv.sh is the single line below. > CATALINA_OPTS='-Xms128m -Xmx256m > -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" > -Dcom.sun.jndi.ldap.connect.pool.timeout=1' So, the above echos fine but causes the NoClassDefFoundError? Try any one of the following, which might work: CATALINA_OPTS="-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol=plain\ ssl - -Dcom.sun.jndi.ldap.connect.pool.timeout=1" CATALINA_OPTS='-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol=plain\ ssl - -Dcom.sun.jndi.ldap.connect.pool.timeout=1' CATALINA_OPTS="-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol=\"plain ssl\" - -Dcom.sun.jndi.ldap.connect.pool.timeout=1" These will probably not work: CATALINA_OPTS="-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol='plain ssl' - -Dcom.sun.jndi.ldap.connect.pool.timeout=1" CATALINA_OPTS='-Xms128m -Xmx256m - -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" - -Dcom.sun.jndi.ldap.connect.pool.timeout=1' I suspect that there is some quoting being done in the catalina.sh script itself which is confusing things. Try looking at the script itself to see where such quoting is being done, and how you might "defeat" it :) - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkousdUACgkQ9CaO5/Lv0PA1QQCfT88n8/vMnkbtiC7wnPgQgdVg 438AmwV8lUADAdBfcWd9VeOZYGJqX2Y6 =zRFk -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
setenv.sh - how to set system properties to values containing spaces
Hi all, I am trying to set the following system property/value in setenv.sh com.sun.jndi.ldap.connect.pool.protocol="plain ssl" on Apache Tomcat/6.0.16, and I cannot for the life of me figure out how to escape the quotes and get the server to start. If I enclose the whole CATALINA_OPTS in single quotes, then the value looks fine when echoed, but the catalina.out contains Exception in thread "main" java.lang.NoClassDefFoundError: ssl" Java (bourne sh) is still not taking the part of the value after the space as part of the value, but as a separate argument (main class name) I have experimented with many options and searched the web for help with this, but, I cannot find anything. Can anybody help with the correct format for CATALINA_OPTS in setenv.sh when setting a system property to a value which contains a space? Thanks in advance, Bap. The complete contents of setenv.sh is the single line below. CATALINA_OPTS='-Xms128m -Xmx256m -Dcom.sun.jndi.ldap.connect.pool.protocol="plain ssl" -Dcom.sun.jndi.ldap.connect.pool.timeout=1' - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org