我最近将我的应用升级为使用v1.3.1,以便我可以删除管理上下文路径问题的解决方法。当我尝试启动应用程序时,它只是抱怨无效的JVM args,但除了弹簧启动版本更改之外,没有更改jvm args或应用程序。
我并排安装了旧版本(w / boot v1.3.0)和新版本(w / boot v1.3.1),这似乎与init.d服务脚本有关。下面是我在vagrant ubuntu主机上并排安装的不同版本的示例服务 -
v0.0.1-218655-SNAPSHOT = with spring boot v1.3.1
v0.0.1-218570-SNAPSHOT = with sprint boot v1.3.0
Ubuntu版
vagrant@account-service-ubuntu:~$ cat /etc/issue
Ubuntu 14.04.3 LTS \n \l
Java版
vagrant@account-service-ubuntu:~$ which java
/opt/java/oracle/jdk1.8.0_60/bin/java
用于自定义启动脚本的服务和conf文件的版本 -
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启动版本 -
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
只是为了澄清启动自定义配置文件之间没有区别 -
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
每个conf文件都有以下环境变量 -
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"
使用使用spring boot v1.3.0的版本启动应用程序并启动正常
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"}}
现在,将符号链接更新为使用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报告服务已启动,但没有进程正在运行,并且在查看控制台日志时失败并出现以下JVM错误 -
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.
如果我直接启动应用程序绕过init脚本并传递启动自定义配置文件中定义的相同环境变量,则启动正常
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"}}
其他人看到了吗?我无法在堆栈溢出时发现任何类似问题的问题。我甚至试图在github上对spring boot v1.3.0和v1.3.1标签进行区分,但没有找到任何明显的东西。
答案 0 :(得分:1)
感谢@StéphaneNicoll进行更新。它修复了管理上下文但引入了init脚本错误,这真是太糟糕了。如果有人提到这些错误会帮助我,因为它会为我节省很多努力。
我能够提取init脚本并在版本之间执行差异,它可能就是这一行 -
command =“$ javaexe -Dsun.misc.URLClassPath.disableJarChecking = true $ JAVA_OPTS -jar $ jarfile $ RUN_ARGS $ *“
在版本v1.3.0中,它是 -
command =“$ javaexe -Dsun.misc.URLClassPath.disableJarChecking = true $ JAVA_OPTS -jar $ jarfile $ RUN_ARGS $ @“
注意$ * vs $ @。我不是shell / bash专家,但我认为这可能是基于 - http://tldp.org/LDP/abs/html/internalvariables.html#IFSEMPTY
的原因