0
votes

I recently upgraded my app to use v1.3.1 so that I can remove workaround for management context path issue. When I try to start the app now it just complains about invalid JVM args but there is not change to jvm args or to the app apart from just spring boot version change.

I installed old (w/ boot v1.3.0) and new (w/ boot v1.3.1) version side by side and it seems something wrong with init.d service script. Below are different versions of example service that I installed side by side on vagrant ubuntu host -

v0.0.1-218655-SNAPSHOT = with spring boot v1.3.1
v0.0.1-218570-SNAPSHOT = with sprint boot v1.3.0

Ubuntu version

vagrant@account-service-ubuntu:~$ cat /etc/issue
Ubuntu 14.04.3 LTS \n \l

Java version

vagrant@account-service-ubuntu:~$ which java
/opt/java/oracle/jdk1.8.0_60/bin/java

Both the version of service and conf file to customize startup scripts -

vagrant@account-service-ubuntu:~$ ls -rtl /var/account-service/
total 64308
-rwxr-xr-x 1 account-service account-service 32941156 Jan  4 11:48 account-service-0.0.1-218655-SNAPSHOT.jar
-rwxr-xr-x 1 account-service account-service      304 Jan  4 11:48 account-service-0.0.1-218655-SNAPSHOT.conf
-rwxr-x--- 1 account-service account-service 32895698 Jan  4 12:09 account-service-0.0.1-218570-SNAPSHOT.jar
-rwxr-x--- 1 account-service account-service      304 Jan  4 12:09 account-service-0.0.1-218570-SNAPSHOT.conf

Spring boot version across the version of application -

vagrant@account-service-ubuntu:~$ sudo /opt/java/oracle/jdk1.8.0_60/bin/jar tf /var/account-service/account-service-0.0.1-218570-SNAPSHOT.jar | grep "spring-boot-1"
lib/spring-boot-1.3.0.RELEASE.jar
vagrant@account-service-ubuntu:~$ sudo /opt/java/oracle/jdk1.8.0_60/bin/jar tf /var/account-service/account-service-0.0.1-218655-SNAPSHOT.jar | grep "spring-boot-1"
lib/spring-boot-1.3.1.RELEASE.jar

Just to clarify that there are no differences between startup customization conf files -

vagrant@account-service-ubuntu:~$ sudo diff /var/account-service/account-service-0.0.1-218570-SNAPSHOT.conf /var/account-service/account-service-0.0.1-218655-SNAPSHOT.conf -s
Files /var/account-service/account-service-0.0.1-218570-SNAPSHOT.conf and /var/account-service/account-service-0.0.1-218655-SNAPSHOT.conf are identical

Each conf file has below environment variables -

vagrant@account-service-ubuntu:~$ cat /var/account-service/account-service-0.0.1-218655-SNAPSHOT.conf 
JAVA_HOME=/opt/java/oracle/jdk1.8.0_60
JAVA_OPTS="-Xms256m -Xmx256m -XX:MaxMetaspaceSize=128m -XX:HeapDumpPath=/var/account-service/ -Xloggc:/var/account-service/gc.log"
RUN_ARGS="--server.tomcat.basedir=/var/account-service/tomcat --spring.profiles.active=dev"

Start the application using version which uses spring boot v1.3.0 and it starts up fine

vagrant@account-service-ubuntu:~$ ls -rtl /etc/init.d/account-service 
lrwxrwxrwx 1 root root 62 Jan  4 12:09 /etc/init.d/account-service -> /var/account-service/account-service-0.0.1-218570-SNAPSHOT.jar

vagrant@account-service-ubuntu:~$ sudo service account-service start
Started [18293]

vagrant@account-service-ubuntu:~$ ps -ef | grep -i java
account+ 19221     1 96 12:10 ?        00:00:05 /opt/java/oracle/jdk1.8.0_60/bin/java -Dsun.misc.URLClassPath.disableJarChecking=true -Xms256m -Xmx256m -XX:MaxMetaspaceSize=128m -XX:HeapDumpPath=/var/account-service/ -Xloggc:/var/account-service/gc.log -jar /var/account-service/account-service-0.0.1-218570-SNAPSHOT.jar --server.tomcat.basedir=/var/account-service/tomcat --spring.profiles.active=dev

vagrant@account-service-ubuntu:~$ curl http://localhost:8081/account/manage/info
{"build":{"artifact":"account-service","name":"Account Service","version":"0.0.1-218570-SNAPSHOT"}}

Now, update the symlink to app version that uses spring boot v1.3.1

vagrant@account-service-ubuntu:~$ sudo service account-service stop
Stopped [19221]

vagrant@account-service-ubuntu:~$ sudo ln -f -s /var/account-service/account-service-0.0.1-218655-SNAPSHOT.jar /etc/init.d/account-service

vagrant@account-service-ubuntu:~$ ls -rtl /etc/init.d/account-service 
lrwxrwxrwx 1 root root 62 Jan  4 12:17 /etc/init.d/account-service -> /var/account-service/account-service-0.0.1-218655-SNAPSHOT.jar

vagrant@account-service-ubuntu:~$ sudo service account-service start
Started [19631]

Shell reports that service started but there is no process running and looking at console log it fails with below JVM error -

vagrant@account-service-ubuntu:~$ cat /var/log/account-service-console.log 
Invalid initial heap size: -Xms256m -Xmx256m -XX:MaxMetaspaceSize=128m -XX:HeapDumpPath=/var/account-service/ -Xloggc:/var/account-service/gc.log
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

If I start the application directly bypassing init script and passing same environment variables as defined in startup customization conf file, it starts up fine

vagrant@account-service-ubuntu:~$ sudo /opt/java/oracle/jdk1.8.0_60/bin/java -Dsun.misc.URLClassPath.disableJarChecking=true -Xms256m -Xmx256m -XX:MaxMetaspaceSize=128m -XX:HeapDumpPath=/var/account-service/ -Xloggc:/var/account-service/gc.log -jar /var/account-service/account-service-0.0.1-218655-SNAPSHOT.jar --server.tomcat.basedir=/var/account-service/tomcat --spring.profiles.active=dev

vagrant@account-service-ubuntu:~$ curl http://localhost:8081/manage/info
{"build":{"artifact":"account-service","name":"Account Service","version":"0.0.1-218655-SNAPSHOT"}}

Anyone else seeing this? I couldn't find any issues like this discussed on stack overflow. I even tried to diff spring boot v1.3.0 and v1.3.1 labels on github and did not find anything obvious.

1
There are a couple of regressions in 1.3.1 and we're aware of the problem. I added a link to this thread in #4872. Please watch for updates. – Stephane Nicoll

1 Answers

1
votes

Thanks @StéphaneNicoll for update. It's bummer that it fixes management context but introduces init script bugs. Would have helped me if there was reference to these bugs as it would have saved me lot of efforts.

I was able to extract init script and perform diff between versions and it may be this line -

command="$javaexe -Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS $*"

In version v1.3.0 it is -

command="$javaexe -Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS $@"

Notice $* vs $@. I am not shell/bash expert but I think that might be the cause based on - http://tldp.org/LDP/abs/html/internalvariables.html#IFSEMPTY