【Azure 应用服务】部署Jar到App Service for Linux,因启动命令路径配置错误而引起:( Application Error 问题

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 【Azure 应用服务】部署Jar到App Service for Linux,因启动命令路径配置错误而引起:( Application Error 问题

问题描述

App Service for Linux 资源创建完成后,通过FTP方式把 .jar包(logdemo.jar)包上传到 /site/wwwroot/ 文件夹后,在App Service的Configration 配置页面配置启动命令为:

java -jar /site/wwwroot/logdemo.jar

但是,在访问App Service时,却是 Application Error 错误 (503 Service Temporarily Unavailable)

 

问题解决

第一步:查看日志

进入App Service的Kudu站点(https://<your app service name>.scm.chinacloudsites.cn/DebugConsole),查看Log Stream,检查错误日志

第二步:分析错误信息

2022-02-19T08:55:59.035870757Z Add private certificates to keystore if exists...
2022-02-19T08:55:59.035875157Z Configuring max heap = 1346 MB
2022-02-19T08:55:59.076047416Z STARTUP_FILE=
2022-02-19T08:55:59.076713522Z STARTUP_COMMAND=java -jar /site/wwwroot/logdemo.jar
2022-02-19T08:55:59.076729422Z No STARTUP_FILE available.
2022-02-19T08:55:59.085391200Z Running STARTUP_COMMAND: java -jar /site/wwwroot/logdemo.jar
2022-02-19T08:55:59.087846422Z Error: Unable to access jarfile /site/wwwroot/logdemo.jar
2022-02-19T08:55:59.095872294Z Finished running startup file 'java -jar /site/wwwroot/logdemo.jar'. Exit code: '1'.
2022-02-19T08:55:59.115095866Z Custom startup complete. Now, exiting with exit code '1'
/home/LogFiles/2022_02_19_lw0sdlwk00005J_docker.log  (https://xxxxx.scm.chinacloudsites.cn/api/vfs/LogFiles/2022_02_19_lw0sdlwk00005J_docker.log)
2022-02-19T08:55:49.578Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-02-19T08:55:49.659Z INFO  - Starting container for site
2022-02-19T08:55:49.660Z INFO  - docker run -d -p 8080:8080 --name lbjavainlinux_0_2fbcc321 -e PORT=8080 -e WEBSITE_SITE_NAME=lbjavainlinux -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=lbjavainlinux.chinacloudsites.cn -e WEBSITE_INSTANCE_ID=f902a04a85d38b0fa81789a73bd7f0fd35ab4400956424760d2a2f982ef05b43 mcr.microsoft.com/azure-app-service/java:8-jre8_210526002747 java -jar /site/wwwroot/logdemo.jar 
2022-02-19T08:55:49.660Z INFO  - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2022-02-19T08:55:58.101Z INFO  - Initiating warmup request to container lbjavainlinux_0_2fbcc321 for site lbjavainlinux
2022-02-19T08:55:59.460Z ERROR - Container lbjavainlinux_0_2fbcc321 for site lbjavainlinux has exited, failing site start
2022-02-19T08:55:59.467Z ERROR - Container lbjavainlinux_0_2fbcc321 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2022-02-19T08:55:59.497Z INFO  - Stopping site lbjavainlinux because it failed during startup.

日志显示,不能访问jar文件 /site/wwwroot/logdemo.jar, 所以站点无法启动。 但是通过Kudu Bash查看App Service的文件,发现logdemo.jar文件时存在的:

 

所以问题根源就是 App Service的Java应用启动命令中,jar包路径配置错误。正确的启动命令为:

java -jar /home/site/wwwroot/logdemo.jar

PS: 因为通过FTP工具显示的文件根路径就是/,并没有/home/显示,所以在Linux环境中,极易忽略home而导致以上错误。

第三步:问题解决,查看日志启动成功

/home/LogFiles/2022_02_19_lw0sdlwk00005J_docker.log  (https://lbjavainlinux.scm.chinacloudsites.cn/api/vfs/LogFiles/2022_02_19_lw0sdlwk00005J_docker.log)
2022-02-19T09:11:02.556Z INFO  - 8-jre8_210526002747 Pulling from azure-app-service/java
2022-02-19T09:11:02.557Z INFO  -  Digest: sha256:b26811cc1b99fc7cfa7485d2313da3abbf0f96f742961908ee7da07ef489ddc6
2022-02-19T09:11:02.557Z INFO  -  Status: Image is up to date for mcr.microsoft.com/azure-app-service/java:8-jre8_210526002747
2022-02-19T09:11:02.565Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-02-19T09:11:02.617Z INFO  - Starting container for site
2022-02-19T09:11:02.617Z INFO  - docker run -d -p 8080:8080 --name lbjavainlinux_0_ffad47c9 -e PORT=8080 -e WEBSITE_SITE_NAME=lbjavainlinux -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=lbjavainlinux.chinacloudsites.cn -e WEBSITE_INSTANCE_ID=f902a04a85d38b0fa81789a73bd7f0fd35ab4400956424760d2a2f982ef05b43 mcr.microsoft.com/azure-app-service/java:8-jre8_210526002747 java -jar /home/site/wwwroot/logdemo.jar 
2022-02-19T09:11:02.637Z INFO  - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2022-02-19T09:11:08.645Z INFO  - Initiating warmup request to container lbjavainlinux_0_ffad47c9 for site lbjavainlinux
/home/LogFiles/webssh/.log  (https://lbjavainlinux.scm.chinacloudsites.cn/api/vfs/LogFiles/webssh/.log)
Ending Log Tail of existing logs ---
Starting Live Log Stream ---
2022-02-19T09:11:08.645Z INFO  - Initiating warmup request to container lbjavainlinux_0_ffad47c9 for site lbjavainlinux
2022-02-19 09:11:22.559  INFO 125 --- [main] com.example.App                          : Starting App v1.0-SNAPSHOT on f60af282340b with PID 125 (/home/site/wwwroot/logdemo.jar started by root in /)
2022-02-19 09:11:23.022  INFO 125 --- [main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@447d90dd: startup date [Sat Feb 19 09:11:23 GMT 2022]; root of context hierarchy
2022-02-19 09:11:29.200  INFO 125 --- [main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2022-02-19 09:11:32.370  INFO 125 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b749a166] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-02-19 09:11:32.721  INFO 125 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-02-19 09:11:32.842  INFO 125 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-02-19 09:11:32.903  INFO 125 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-02-19 09:11:37.004  INFO 125 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2022-02-19T09:11:40.611Z INFO  - Waiting for response to warmup request for container lbjavainlinux_0_ffad47c9. Elapsed time = 31.9663615 sec
2022-02-19 09:11:40.594  INFO 125 --- [main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2022-02-19 09:11:40.633  INFO 125 --- [main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.28
2022-02-19 09:11:41.800  INFO 125 --- [localhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-02-19 09:11:41.819  INFO 125 --- [localhost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 18816 ms
2022-02-19 09:11:48.263  INFO 125 --- [localhost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2022-02-19 09:11:48.295  INFO 125 --- [localhost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2022-02-19 09:11:48.304  INFO 125 --- [localhost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2022-02-19 09:11:51.478  INFO 125 --- [main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@447d90dd: startup date [Sat Feb 19 09:11:23 GMT 2022]; root of context hierarchy
2022-02-19 09:11:52.406  INFO 125 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto java.lang.String com.example.HelloController.hello()
2022-02-19 09:11:52.412  INFO 125 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/newhello]}" onto java.lang.String com.example.HelloController.hello2()
2022-02-19 09:11:52.422  INFO 125 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2022-02-19 09:11:52.435  INFO 125 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2022-02-19 09:11:52.666  INFO 125 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-02-19 09:11:52.684  INFO 125 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-02-19 09:11:53.066  INFO 125 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-02-19T09:11:55.939Z INFO  - Waiting for response to warmup request for container lbjavainlinux_0_ffad47c9. Elapsed time = 47.2941072 sec
2022-02-19 09:11:55.146  INFO 125 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2022-02-19 09:11:55.950  INFO 125 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2022-02-19 09:11:56.000  INFO 125 --- [main] com.example.App                          : Started App in 35.854 seconds (JVM running for 40.855)
2022-02-19 09:11:56.002  INFO 125 --- [main] com.example.App                          : test java logs  : info
2022-02-19 09:11:56.010 ERROR 125 --- [main] com.example.App                          : test java logs  : error
2022-02-19 09:11:56.012  WARN 125 --- [main] com.example.App                          : test java logs  : warn
2022-02-19 09:11:56.409  INFO 125 --- [http-nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2022-02-19 09:11:56.413  INFO 125 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2022-02-19 09:11:56.545  INFO 125 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 131 ms
2022-02-19T09:11:57.181Z INFO  - Container lbjavainlinux_0_ffad47c9 for site lbjavainlinux initialized successfully and is ready to serve requests.

Java应用启动完成!

 

 

参考资料

为 Azure 应用服务配置 Java 应用: https://docs.azure.cn/zh-cn/app-service/configure-language-java?pivots=platform-linux#java-se

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
15天前
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
126 77
|
1月前
|
Windows
【Azure App Service】对App Service中CPU指标数据中系统占用部分(System CPU)的解释
在Azure App Service中,CPU占比可在App Service Plan级别查看整个实例的资源使用情况。具体应用中仅能查看CPU时间,需通过公式【CPU Time / (CPU核数 * 60)】估算占比。CPU百分比适用于可横向扩展的计划(Basic、Standard、Premium),而CPU时间适用于Free或Shared计划。然而,CPU Percentage包含所有应用及系统占用的CPU,高CPU指标可能由系统而非应用请求引起。详细分析每个进程的CPU占用需抓取Windows Performance Trace数据。
94 40
|
3月前
|
Java 开发工具 Windows
【Azure App Service】在App Service中调用Stroage SDK上传文件时遇见 System.OutOfMemoryException
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
|
4天前
|
JavaScript 搜索推荐 Android开发
【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
23 8
【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
|
8天前
|
安全 JavaScript 前端开发
小游戏源码开发之可跨app软件对接是如何设计和开发的
小游戏开发团队常需应对跨平台需求,为此设计了成熟的解决方案。流程涵盖游戏设计、技术选型、接口设计等。首先明确游戏功能与特性,选择合适的技术架构和引擎(如Unity或Cocos2d-x)。接着设计通用接口,确保与不同App的无缝对接,并制定接口规范。开发过程中实现游戏逻辑和界面,完成登录、分享及数据对接功能。最后进行测试优化,确保兼容性和性能,发布后持续维护更新。
|
10天前
|
前端开发 Java 测试技术
语音app系统软件源码开发搭建新手启蒙篇
在移动互联网时代,语音App已成为生活和工作的重要工具。本文为新手开发者提供语音App系统软件源码开发的启蒙指南,涵盖需求分析、技术选型、界面设计、编码实现、测试部署等关键环节。通过明确需求、选择合适的技术框架、优化用户体验、严格测试及持续维护更新,帮助开发者掌握开发流程,快速搭建功能完善的语音App。
|
10天前
|
机器学习/深度学习 存储 人工智能
MNN-LLM App:在手机上离线运行大模型,阿里巴巴开源基于 MNN-LLM 框架开发的手机 AI 助手应用
MNN-LLM App 是阿里巴巴基于 MNN-LLM 框架开发的 Android 应用,支持多模态交互、多种主流模型选择、离线运行及性能优化。
859 14
MNN-LLM App:在手机上离线运行大模型,阿里巴巴开源基于 MNN-LLM 框架开发的手机 AI 助手应用
|
11天前
|
前端开发 安全 开发工具
【11】flutter进行了聊天页面的开发-增加了即时通讯聊天的整体页面和组件-切换-朋友-陌生人-vip开通详细页面-即时通讯sdk准备-直播sdk准备-即时通讯有无UI集成的区别介绍-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【11】flutter进行了聊天页面的开发-增加了即时通讯聊天的整体页面和组件-切换-朋友-陌生人-vip开通详细页面-即时通讯sdk准备-直播sdk准备-即时通讯有无UI集成的区别介绍-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
139 90
【11】flutter进行了聊天页面的开发-增加了即时通讯聊天的整体页面和组件-切换-朋友-陌生人-vip开通详细页面-即时通讯sdk准备-直播sdk准备-即时通讯有无UI集成的区别介绍-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
|
12天前
|
供应链 数据挖掘 API
1688APP 原数据 API 接口的开发、应用与收益
1688作为阿里巴巴旗下的B2B平台,汇聚海量供应商和商品资源。其APP原数据API接口为开发者提供获取商品详细信息的强大工具,涵盖商品标题、价格、图片等。通过注册开放平台账号、申请API权限并调用接口,开发者可构建比价工具、供应链管理及自动化上架工具等应用,提升用户体验与运营效率,创造新的商业模式。示例代码展示了如何使用Python调用API并解析返回结果。
65 8
|
14天前
|
Dart 前端开发 Android开发
【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
37 4
【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex

热门文章

最新文章

  • 1
    【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
    33
  • 2
    【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
    28
  • 3
    【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
    23
  • 4
    【Azure Function】Function App门户上的Test/Run返回错误:Failed to fetch
    30
  • 5
    陪玩APP推送配置:陪玩系统手机锁屏收不到推送?可能是这些原因!解决方案来了!
    34
  • 6
    小游戏源码开发之可跨app软件对接是如何设计和开发的
    32
  • 7
    原生鸿蒙版小艺APP接入DeepSeek-R1,为HarmonyOS应用开发注入新活力
    134
  • 8
    PiliPala:开源项目真香,B站用户狂喜!这个开源APP竟能自定义主题+去广告?PiliPala隐藏功能大揭秘
    60
  • 9
    语音app系统软件源码开发搭建新手启蒙篇
    44
  • 10
    MNN-LLM App:在手机上离线运行大模型,阿里巴巴开源基于 MNN-LLM 框架开发的手机 AI 助手应用
    859