[Geoserver-devel] Broken JAVA_OPTS handling in startup.sh

Hello

In geoserver 2.20.x the startup.sh of the platform independent binary distribution has been refactored

2.19.x:
exec “$_RUNJAVA” $JAVA_OPTS $MARLIN_ENABLER -DGEOSERVER_DATA_DIR=“$GEOSERVER_DATA_DIR” -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar

2.20.x:
IFS=$(printf ‘\n\t’)

exec “${_RUNJAVA}” “${JAVA_OPTS:–DNoJavaOpts}” “${MARLIN_ENABLER:–DMarlinDisabled}” “${RENDERER:–DDefaultrenderer}” “-Djetty.base=${GEOSERVER_HOME}” “-DGEOSERVER_DATA_DIR=${GEOSERVER_DATA_DIR}” -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar “${GEOSERVER_HOME}/start.jar”

This doesn’t allow setting multiple parameters in JAVA_OPTS anymore because it will be passed to exec as one argument.

Reproduce like this:

  1. Download and extract the zip file
  2. cd geoserver-2.20.2-bin
  3. export JAVA_OPTS=“-Xms512m -Xmx1g”
  4. bin/startup.sh

Result:
GEOSERVER_HOME environment variable not found, using current
directory. If not set then running this script from other
directories will not work in the future.
GEOSERVER DATA DIR is /vagrant/geoserver-2.20.2-bin/data_dir
Invalid initial heap size: -Xms512m -Xmx1g
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

By setting set -x before the call one can see that the parameters are passed as one argument:

  • exec java ‘-Xms512m -Xmx1g’ -Xbootclasspath/a:/vagrant/geoserver-2.20.2-bin/webapps/geoserver/WEB-INF/lib/marlin-0.9.3.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine -Djetty.base=/vagrant/geoserver-2.20.2-bin -DGEOSERVER_DATA_DIR=/vagrant/geoserver-2.20.2-bin/data_dir -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar /vagrant/geoserver-2.20.2-bin/start.jar

By removing ‘IFS=$(printf ‘\n\t’)’ and removing the quotation marks from “${JAVA_OPTS:–DNoJavaOpts}” this will work again:

  • exec java -Xms512m -Xmx1g -Xbootclasspath/a:/vagrant/geoserver-2.20.2-bin/webapps/geoserver/WEB-INF/lib/marlin-0.9.3.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine -Djetty.base=/vagrant/geoserver-2.20.2-bin -DGEOSERVER_DATA_DIR=/vagrant/geoserver-2.20.2-bin/data_dir -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar /vagrant/geoserver-2.20.2-bin/start.jar

I guess the same applies to other variables if the contain multiple arguments.

Would be great if setting multiple parameters in JAVA_OPTS will be supported again.

Regards,
Björn

I believe a fix for that has already been done on the main branch:
https://github.com/geoserver/geoserver/pull/5415

Do you have time to issue a backport PR against 2.20.x?

Cheers
Andrea

···

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 333 8128928

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi Andrea

Sorry, I totally missed that with the mailing list search.

I created a pull request for 20.2.x:
https://github.com/geoserver/geoserver/pull/5623

Regards,

Björn

Am Mi., 26. Jan. 2022 um 15:56 Uhr schrieb Andrea Aime <andrea.aime@anonymised.com>:

I believe a fix for that has already been done on the main branch:
https://github.com/geoserver/geoserver/pull/5415

Do you have time to issue a backport PR against 2.20.x?

Cheers
Andrea

On Wed, Jan 26, 2022 at 2:20 PM Björn Küng <bjoern.kueng@anonymised.com> wrote:

Hello

In geoserver 2.20.x the startup.sh of the platform independent binary distribution has been refactored

2.19.x:
exec “$_RUNJAVA” $JAVA_OPTS $MARLIN_ENABLER -DGEOSERVER_DATA_DIR=“$GEOSERVER_DATA_DIR” -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar

2.20.x:
IFS=$(printf ‘\n\t’)

exec “${_RUNJAVA}” “${JAVA_OPTS:–DNoJavaOpts}” “${MARLIN_ENABLER:–DMarlinDisabled}” “${RENDERER:–DDefaultrenderer}” “-Djetty.base=${GEOSERVER_HOME}” “-DGEOSERVER_DATA_DIR=${GEOSERVER_DATA_DIR}” -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar “${GEOSERVER_HOME}/start.jar”

This doesn’t allow setting multiple parameters in JAVA_OPTS anymore because it will be passed to exec as one argument.

Reproduce like this:

  1. Download and extract the zip file
  2. cd geoserver-2.20.2-bin
  3. export JAVA_OPTS=“-Xms512m -Xmx1g”
  4. bin/startup.sh

Result:
GEOSERVER_HOME environment variable not found, using current
directory. If not set then running this script from other
directories will not work in the future.
GEOSERVER DATA DIR is /vagrant/geoserver-2.20.2-bin/data_dir
Invalid initial heap size: -Xms512m -Xmx1g
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

By setting set -x before the call one can see that the parameters are passed as one argument:

  • exec java ‘-Xms512m -Xmx1g’ -Xbootclasspath/a:/vagrant/geoserver-2.20.2-bin/webapps/geoserver/WEB-INF/lib/marlin-0.9.3.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine -Djetty.base=/vagrant/geoserver-2.20.2-bin -DGEOSERVER_DATA_DIR=/vagrant/geoserver-2.20.2-bin/data_dir -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar /vagrant/geoserver-2.20.2-bin/start.jar

By removing ‘IFS=$(printf ‘\n\t’)’ and removing the quotation marks from “${JAVA_OPTS:–DNoJavaOpts}” this will work again:

  • exec java -Xms512m -Xmx1g -Xbootclasspath/a:/vagrant/geoserver-2.20.2-bin/webapps/geoserver/WEB-INF/lib/marlin-0.9.3.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine -Djetty.base=/vagrant/geoserver-2.20.2-bin -DGEOSERVER_DATA_DIR=/vagrant/geoserver-2.20.2-bin/data_dir -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar /vagrant/geoserver-2.20.2-bin/start.jar

I guess the same applies to other variables if the contain multiple arguments.

Would be great if setting multiple parameters in JAVA_OPTS will be supported again.

Regards,
Björn


Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 333 8128928

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail