user3667111
user3667111

Reputation: 631

Azure uploaded jar but doesn't run it (Spring boot)

I've got myself an Azure Web App Service and a SQL database to go with it. I'm using Azures Intellij plugin to "Run On Web App". Issue is, it doesn't run anything, however it does put the jar in the folder:

Connecting to FTP server...
Uploading artifact to: /site/wwwroot/ROOT.jar ...
Uploading successfully...
Start Web App...
Logging out of FTP server...
Deploy successfully!

I then, using console try to run the ROOT.jar by using java -jar ROOT.jar, but I get the error message

Java is not recognised as an internal command or external command

In the webapp application settings I have Java Version: Java 8 So I'd assume it'd give me the ability to run java, but this has just made me question the way I'm doing it. Am I deploying the app wrong?

Upvotes: 0

Views: 1365

Answers (1)

Peter Pan
Peter Pan

Reputation: 24138

It sounds like your SpringBoot project lacked a web.config file which will be deployed at the path wwwroot for helping to handle your ROOT.jar.

Here is a sample web.config file for SpringBoot runnable jar.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\ROOT.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

As above, it comes from my answer of a similar SO thread Deploying Springboot to Azure App Service which you can refer to.

Upvotes: 1

Related Questions