无法在Azure Web应用中运行核心Java Web应用。

huangapple 未分类评论45阅读模式
英文:

Can't run Core Java web application into Azure Web app

问题

以下是翻译好的内容:

我已经使用maven-archetype-webapp编写了一个核心Java Web应用程序,尝试将jar文件和web.config部署在基于Azure Windows的Web应用程序中,但无法访问URL。我的应用程序中只有主页。并且按照以下步骤操作。我能够在本地系统中运行它并且可以看到主页。

  1. 在POM中添加了azure-webapp-maven-plugin,并使用mvn azure-webapp:config进行构建,然后在configuration标签内添加了以下标签。
<appSettings>
    <property>
        <name>JAVA_OPTS</name>
        <value>-Dserver.port=80</value>
    </property>
</appSettings>
  1. 使用Java 8和Tomcat 8.5在Windows上创建了Web应用程序。
  2. 将jar文件和web.config文件部署到wwwroot目录中。

Web.config

<?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\TestWebApp.jar&quot;">
        </httpPlatform>
    </system.webServer>
</configuration>

文件夹结构

(图片已省略)

Azure目录结构

(图片已省略)

本地系统输出

(图片已省略)

英文:

I have written a core java web application using maven-archetype-webapp and trying to deploy the jar file and web.config in a azure windows based webapp but not able to access the url. I only have home page inside my application. and following below steps. I am able to run it in my local system and can see the homepage.

  1. azure-webapp-maven-plugin added in POM and build with mvn azure-webapp:config, then inside configuration tag I added below tag.
&lt;appSettings&gt;
    &lt;property&gt;
        &lt;name&gt;JAVA_OPTS&lt;/name&gt;
        &lt;value&gt;-Dserver.port=80&lt;/value&gt;
    &lt;/property&gt;
&lt;/appSettings&gt;
  1. Created a web app in Windowsusing Java 8 and Tomcat 8.5
  2. Deployed jar file and web.config file inside wwwroot directory

Web.config

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

Folder Structure

无法在Azure Web应用中运行核心Java Web应用。

Azure directory structure

无法在Azure Web应用中运行核心Java Web应用。

Local system Output:

无法在Azure Web应用中运行核心Java Web应用。

答案1

得分: 0

感谢@soumen提供的解决方案。

> 将war文件部署在Azure的webapp中的wwwroot文件夹中。
> 在部署之前删除了webapps中的Root文件夹,在我的部署之后,新的根文件夹被自动生成,现在我可以访问该URL。

我将其视为一个答案,希望能帮助其他成员。

英文:

Thanks @soumen for the solution.

> Deployed the war file inside wwwroot -> webapps folder in azure
> webapp. Before deploying deleted the Root folder inside webapps, after
> my deployment new root folder was automatically generated, now I can
> access the url.

I take it as an answer, hoping to help other members.

huangapple
  • 本文由 发表于 2020年7月25日 19:41:44
  • 转载请务必保留本文链接:https://java.coder-hub.com/63087905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定