【问题标题】:Spring boot shut downs (really) immediately on remote server with no errorSpring Boot 在远程服务器上立即关闭(真的),没有错误
【发布时间】:2018-08-09 13:26:43
【问题描述】:

我使用package maven 插件构建了一个spring 应用程序的jar。在本地,我可以运行它 java -jar -Dspring.profiles.active=dev target/my.jar 并且一切正常

然后我使用scp 将jar 复制到远程服务器,使用ssh 登录,复制我的应用程序需要的所有资源并尝试运行。这是我得到的:

user@server:~$ java -jar -Dspring.profiles.active=dev target/my.jar -debug
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.9.RELEASE)

[INFO ] 2018-03-01 13:37:02                  com.ws.eb.MyApplication - Starting MyApplication v1.0 with PID 16806 (/home/user/target/my.jar started by suirz in /home/user)
[DEBUG] 2018-03-01 13:37:02                  com.ws.eb.MyApplication - Running with Spring Boot v1.5.9.RELEASE, Spring v4.3.13.RELEASE
[INFO ] 2018-03-01 13:37:02                  com.ws.eb.MyApplication - The following profiles are active: dev
user@server:~$ 

没有错误信息。

我尝试使用不同的配置文件(开发/测试/生产),将文件所有者更改为我并得到相同的输出。我尝试使用 jdk-9 和 jdk1.8 运行它。我在 IntelliJ Idea 中开发。与我的本地机器有什么不同?如何打印有关问题的更多信息?

我意识到关于 SO 有很多类似的问题,但每个问题都有一些错误消息。

dmesg 输出:

[    7.803955] [drm] Max GMR ids is 64
[    7.803958] [drm] Max number of GMR pages is 65536
[    7.803960] [drm] Max dedicated hypervisor surface memory is 0 kiB
[    7.803963] [drm] Maximum display memory size is 4096 kiB
[    7.803966] [drm] VRAM at 0xe8000000 size is 4096 kiB
[    7.803969] [drm] MMIO at 0xfe000000 size is 256 kiB
[    7.806320] [drm] global init.
[    7.808880] [TTM] Zone  kernel: Available graphics memory: 4087984 kiB
[    7.808884] [TTM] Zone   dma32: Available graphics memory: 2097152 kiB
[    7.808887] [TTM] Initializing pool allocator
[    7.808897] [TTM] Initializing DMA pool allocator
[    7.811195] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    7.811202] [drm] No driver support for vblank timestamp query.
[    7.812224] [drm] Screen objects system initialized
[    7.812351] [drm] width 640
[    7.812372] [drm] height 480
[    7.812393] [drm] bpp 32
[    7.817482] [drm] Fifo max 0x00040000 min 0x00001000 cap 0x0000077f
[    7.840594] fbcon: svgadrmfb (fb0) is primary device
[    7.891478] Console: switching to colour frame buffer device 100x37
[    7.894293] [drm] Initialized vmwgfx 2.6.1 20140704 for 0000:00:0f.0 on minor 0
[    8.003994] AVX version of gcm_enc/dec engaged.
[    8.004001] AES CTR mode by8 optimization enabled
[    8.156934] audit: type=1400 audit(1515139563.865:2): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/sbin/dhclient" pid=589 comm="apparmor_parser"
[    8.156948] audit: type=1400 audit(1515139563.865:3): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=589 comm="apparmor_parser"
[    8.156957] audit: type=1400 audit(1515139563.865:4): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=589 comm="apparmor_parser"
[    8.157796] audit: type=1400 audit(1515139563.865:5): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=589 comm="apparmor_parser"
[    8.157805] audit: type=1400 audit(1515139563.865:6): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=589 comm="apparmor_parser"
[    8.158244] audit: type=1400 audit(1515139563.865:7): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=589 comm="apparmor_parser"
[    8.188649] intel_rapl: no valid rapl domains found in package 0
[    8.269314] ppdev: user-space parallel port driver
[    8.270832] vmxnet3 0000:03:00.0 eth0: intr type 3, mode 0, 5 vectors allocated
[    8.274863] vmxnet3 0000:03:00.0 eth0: NIC Link is Up 10000 Mbps
[    8.594646] init: failsafe main process (636) killed by TERM signal
[    8.708205] audit: type=1400 audit(1515139564.413:8): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/sbin/dhclient" pid=925 comm="apparmor_parser"
[    8.708231] audit: type=1400 audit(1515139564.413:9): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=925 comm="apparmor_parser"
[    8.708246] audit: type=1400 audit(1515139564.413:10): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=925 comm="apparmor_parser"
[    8.709706] audit: type=1400 audit(1515139564.417:11): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/sbin/tcpdump" pid=927 comm="apparmor_parser"
[   10.251903] NET: Registered protocol family 40
[  471.712509] init: tty1 main process ended, respawning

(执行jar后不变)

更新

  1. 我创建了一个虚拟的空 spring 项目,它可以在本地和远程服务器上运行。
  2. 我已经清除了 maven 库缓存
  3. 我已经重新创建了我的项目并摆脱了一些依赖项,但仍然没有运气

好消息:重新创建的项目不能在本地工作。也许是依赖关系,也许是一些缺失或冲突的 jar。

好消息 2:从 Idea 内部运行 spring boot 时,我收到一些警告消息!

现在的输出是:

连接到目标VM,地址:'127.0.0.1:44323',传​​输:'socket' /home/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar 中的 Class-Path manifest 属性引用了一个或多个不存在的文件:file:/home/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-api.jar,file:/home/user/。 m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/activation.jar,文件:/home/user/.m2/repository/com/sun/xml/bind/jaxb-impl/ 2.2.3-1/jsr173_1.0_api.jar,文件:/home/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb1-impl.jar /home/user/.m2/repository/org/htmlparser/htmlparser/2.1/htmlparser-2.1.jar 中的 Class-Path 清单属性引用了一个或多个不存在的文件:file:/home/user/.m2/存储库/org/htmlparser/htmlparser/2.1/sax-2.0.1.jar,文件:/home/user/.m2/repository/org/htmlparser/htmlparser/2.1/htmllexer-2.1.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_||))))) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|===============|___/=/_/_/_/ :: Spring Boot :: (v1.5.9.RELEASE) [信息] 2018-03-05 11:14:03 com.ws.my.MyApplication - 在 PID 5593 的用户 msi 上启动 MyApplication(/export/home/workspace/my/employemYackend/target/classes 由用户在 /出口/家庭/工作区/我的) [DMYUG] 2018-03-05 11:14:03 com.ws.my.MyApplication - 使用 Spring Boot v1.5.9.RELEASE、Spring v4.3.13.RELEASE 运行 [INFO] 2018-03-05 11:14:03 com.ws.my.MyApplication - 以下配置文件处于活动状态:dev 与目标 VM 断开连接,地址:'127.0.0.1:44323',传​​输:'socket' 进程以退出代码 0 结束

我的 pom 文件

主人

https://pastebin.com/cKAKTriq

新的 Spring Boot 应用程序

https://pastebin.com/PBwmH2wZ

旧的遗留模块(“commonJars”),一些代码日期为 2003 年。

https://pastebin.com/rQ37HNLL

【问题讨论】:

  • dmesg 说什么?由于某种原因,操作系统可能会终止该进程。
  • 我已经运行了dmesg,然后尝试再次运行我的 jar,它成功了!有关系吗?
  • 我非常怀疑这一点。我试图帮助您调试,但显然您从中得到的只是“如果某些东西不起作用,请尝试运行dmesg,然后它可能会起作用”。
  • update2:我的“万岁成功”是误报,我在错误的(本地)终端选项卡中执行了它。我刚刚从远程服务器发布了 dmesg。
  • 你是在linux环境下运行你的jar文件吗?如果是,您应该作为服务运行,而不是通过 java -jar..

标签: java spring spring-boot deployment


【解决方案1】:

我发现缺少日志的问题在于我创建的logback.xml 以自定义日志消息。删除它后,打印了错误消息,我能够解决实际错误(这是关于 tomcat 没有启动的问题,与这个问题无关)。

【讨论】:

    猜你喜欢
    • 2019-11-01
    • 2019-01-22
    • 2020-09-22
    • 2016-04-12
    • 1970-01-01
    • 2019-06-03
    • 2021-07-29
    相关资源
    最近更新 更多