【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)


image

问题解决

第一步:查看日志

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

image

第二步:分析错误信息

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文件时存在的:


image

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

java -jar /home/site/wwwroot/logdemo.jar</pre>

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应用启动完成!


image

参考资料

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

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

分类: 【Azure 应用服务】

标签: App Service, Azure Developer, JaveSE 启动Jar包路径问题, 503 Service Temporarily Unavailable, Application Error 错误

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,319评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,801评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,567评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,156评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,019评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,090评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,500评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,192评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,474评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,566评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,338评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,212评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,572评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,890评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,169评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,478评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,661评论 2 335

推荐阅读更多精彩内容