question

Shashank-8824 avatar image
0 Votes"
Shashank-8824 asked YAZ84-4085 answered

Unable to start spring boot application deployed as a jar

The server shows the below log on start up
2019-12-16T01:20:06.181601108Z Setup openrc ...
2019-12-16T01:20:07.748898646Z Caching service dependencies ... [ ok ]
2019-12-16T01:20:07.898335455Z Updating /etc/ssh/sshd_config to use PORT 2222
2019-12-16T01:20:07.955772472Z Starting ssh service...
2019-12-16T01:20:19.245862428Z ssh-keygen: generating new host keys:

2019-12-16T01:20:21.474320087Z
Starting sshd ... [ ok ]
2019-12-16T01:20:21.497078927Z Skipping AzMon configuration
2019-12-16T01:20:21.503375905Z Add public certificates to keystore if exists...
2019-12-16T01:20:21.503744615Z Add private certificates to keystore if exists...
2019-12-16T01:20:21.504181127Z Initializing App Insights applicationinsights-agent-codeless-2.5.0.jar....
2019-12-16T01:20:21.526961369Z STARTUP_FILE=
2019-12-16T01:20:21.527520685Z STARTUP_COMMAND=
2019-12-16T01:20:21.533224645Z No STARTUP_FILE available.
2019-12-16T01:20:21.542472006Z No STARTUP_COMMAND defined.
2019-12-16T01:20:21.563167889Z Using parking page app with APP_JAR_PATH=/tmp/appservice/parkingpage.jar
2019-12-16T01:20:21.563811907Z Running command: java -noverify -D server.port=80 -jar /tmp/appservice/parkingpage.jar
2019-12-16T01:20:21.564444325Z Launched child process with pid: 121
2019-12-16T01:20:21.578266414Z Waiting for main process to exit. global_pid_main=121
2019-12-16T01:20:21.578731127Z Waiting for global_pid_main == 121
2019-12-16T01:20:21.747695685Z Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/local/app_insights/applicationinsights-agent-codeless-2.5.0.jar -Djava.net.preferIPv4Stack=true
2019-12-16T01:20:31.086210980Z Error: Could not find or load main class server.port=80
2019-12-16T01:20:32.632865237Z Wait for pid == 121 either returned successfully or was interrupted due to a signal 121
2019-12-16T01:20:32.633583957Z Done waiting for main process. global_pid_main=121.
2019-12-16T01:20:32.634237476Z Exiting entry script!
My pom.xml buils is as below

 ABC
     
       
     com.microsoft.azure  
     azure-webapp-maven-plugin  
     1.8.0  
         
       V2  
       ABC-resources  
       ABC  
       B1  
       centralus  
           
         linux  
         jre8  
         jre8 
            
           
             
           JAVA_OPTS  
           -D server.port=80 
             
            
           
             
               
             ${project.basedir}/target  
                 
               *.jar 

I am not sure of this entry in the start up log and think this could be an issue

2019-12-16T01:20:21.563167889Z Using parking page app with APP_JAR_PATH=/tmp/appservice/parkingpage.jar
2019-12-16T01:20:21.563811907Z Running command: java -noverify -D server.port=80 -jar /tmp/appservice/parkingpage.jar

Can you please help?

Thanks,
Shashank

azure-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered

@Shashank, Welcome to Microsoft Q&A! Thanks for posting this question.

Ensure that the jar package name configured in web.config is the same as the uploaded jar package name. To publish jar files and web.config to D:\home\site\wwwroot\ directory on KUDU (http://yourwebapp name.scm.azurewebsites.net).
Add the section to the section of to listen on the 80 port.

App Service Linux routes incoming requests to port 80, so your application should listen on port 80 as well. You can do this in your application's configuration (such as Spring's application.properties file), or in your Startup Command (for example, java -jar spring-app.jar --server.port=80).

If ‘Always On’ config is not turned On, please do turn it on. The AlwaysOn would help keep the app loaded even when there's no traffic, it will send a request to the ROOT of your application. Whatever file is delivered when a request is made to / is the one which will be warmed up and this feature comes with the App Service Plan is not charged separately.

You can configure the amount of time the platform will wait before it restarts your container. To do so, set the WEBSITES_CONTAINER_START_TIME_LIMIT app setting to the value you want.

Default Value = 230 Sec.

Max Value= 1800 Sec

The default value is 230 seconds, and the maximum value is 1800 seconds.


{
"name": "WEBSITES_CONTAINER_START_TIME_LIMIT",
"value": 1800
},


Kindly checkout the document’ Deploy a Spring Boot JAR file app to Azure App Service with Maven and Azure on Linux’ for a more detailed process/step-step instructions for provisioning the app.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JasonFreeberg-3971 avatar image
1 Vote"
JasonFreeberg-3971 answered

Hi, you have two options:

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YAZ84-4085 avatar image
0 Votes"
YAZ84-4085 answered

@JasonFreeberg-3971 , I used as a solution the startup command from the Release pipeline configuration. In my case: "java -jar /home/site/wwwroot/demo-0.0.1-SNAPSHOT.jar --server.port=80". I noticed the name of the artifact in my case from the Build pipeline is <artifactId>+<version> from the pom.xml file, so demo-0.0.1-SNAPSHOT.jar .
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
Then I could see the in Release pipeline /Initialize job logs the message "[PARAMETERS_STARTUPCOMMAND] --> [java -jar /home/site/wwwroot/demo-0.0.1-SNAPSHOT.jar --server.port=80]" . And now Web App URL shows the content of the source code. Previously it was showing the default content, like "Hey, Java developers!".

Question please: When you say "Rename the JAR to app.jar", when and where to perform this renaming? I mention I used for the .jar build an Azure DevOps buid pipeline with copy and publish and in the release pipeline I used as source the build from the previous build pipeline. Thank you.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.