gpt4 book ai didi

java - IBM bluemix 迁移war 文件

转载 作者:太空宇宙 更新时间:2023-11-04 13:19:35 25 4
gpt4 key购买 nike

我对 IBM Liberty 服务器和 Bluemix 都比较陌生。我现有的 Web 应用程序作为 war 部署在本地 WebSphere Liberty 服务器(版本 8.5.5.7)中,并且运行良好,没有任何问题。

然而,当我将 war 文件推送到 IBM Bluemix Liberty 服务器时,真正的问题出现了。我尝试通过两种方式推送本地应用程序。

选项 1

在这里,我将我的应用程序导出为与目标运行时作为IBM组下的WebSphere Liberty服务器的 war ,然后使用cf push <appname> -p <app.war>

这不会在上传时给我任何错误,但我无法使用给定的上下文根访问应用程序。

喜欢http://<appname>.mybluemix.net/<<root>>/login.jsp哪里<<appname>>是应用程序的名称,<<root>>是 war 文件的名称。

通过这些配置,我可以访问部署在本地 Liberty 服务器中的应用程序,但不能访问部署在蓝色混合。此处 Bluemix 无法找到 Web 应用程序的上下文。

选项 2

在这里,我点击下面的链接并尝试了那里提到的所有步骤:

https://developer.ibm.com/answers/questions/25346/liberty-profile-with-webapp-zip-package-onto-the-bluemix-problem.html

我用war打包了整个服务器并尝试部署整个server.zip

server.bat package defaultServer ––include=usr
cf push icmconsole -p E:\softwares\liberty\wlp-javaee7-8.5.5.7\wlp\usr\servers\defaultServer\defaultServer.zip

上传实例后似乎崩溃并在日志中给出以下错误:

2015-10-15T13:58:29.10+0530 [API/0]      OUT App instance exited with guid 50ff6
9b3-58de-4453-b795-2c58cf1b3fdc payload: {"cc_partition"=>"default", "droplet"=>
"50ff69b3-58de-4453-b795-2c58cf1b3fdc", "version"=>"d0097634-3404-47c9-8848- 324c
c6b08315", "instance"=>"a75978ad7c88496ea3c36d1dbc277b34", "index"=>0, "reason"=
>"CRASHED", "exit_status"=>0, "exit_description"=>"failed to accept connections
within health check timeout", "crash_timestamp"=>1444897709}

我的 server.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

<!-- Enable features -->
<featureManager>
<feature>javaee-7.0</feature>
</featureManager>

<!-- This template enables security. To get the full use of all the capabilities, a keystore and user registry are required. -->
<!-- For the keystore, default keys are generated and stored in a keystore. To provide the keystore password, generate an encoded password using bin/securityUtility encode and add it below in the password attribute of the keyStore element. Then uncomment the keyStore element. -->
<!-- <keyStore password=""/> -->
<!--For a user registry configuration, configure your user registry. For example, configure a basic user registry using the basicRegistry element. Specify your own user name below in the name attribute of the user element. For the password, generate an encoded password using bin/securityUtility encode and add it in the password attribute of the user element. Then uncomment the user element. -->

<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>

<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint" httpPort="9080" httpsPort="9443" />

</server>

web.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>mCaaS</display-name>

<servlet>
<servlet-name>MCaaSServletloggedin</servlet-name>
<servlet-class>com.example.myproject.loggedin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MCaaSServletloggedin</servlet-name>
<url-pattern>/mcaas</url-pattern>
</servlet-mapping>

<servlet>
<display-name>MCaaSServletonClose</display-name>
<servlet-name>MCaaSServletonClose</servlet-name>
<servlet-class>com.example.myproject.MCaaSServletonClose</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MCaaSServletonClose</servlet-name>
<url-pattern>/onClose</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>ImageCreator</display-name>
<servlet-name>ImageCreator</servlet-name>
<servlet-class>com.example.myproject.ImageCreator</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageCreator</servlet-name>
<url-pattern>/ic.jpg</url-pattern>
</servlet-mapping>

<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/jsp/500.jsp</location>
</error-page>

<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

你们能帮我解答一下我的问题吗?看来我缺少一些配置。任何帮助将不胜感激。

最佳答案

选项 1

是更简单的。我相信你的应该可以工作,问题是你可能试图从错误的根上下文启动应用程序。

当您使用选项 1 时,Liberty buildpack 将在内部修改您的 war 文件。它将您的 war 文件重命名为 myapp.war 并将根上下文放入“/”中。

因此,根据您的情况,您应该能够从以下位置访问您的应用程序:

http://<appname>.mybluemix.net/login.jsp

您不必指定根目录。

选项 2

比较复杂。我在本地运行了一个简单的测试,效果很好。

这是我所做的:

  1. 我将 Java 应用程序从 Eclipse 部署到 Liberty 服务器的本地实例

  2. 我运行以下命令来创建 zip 文件(需要先停止服务器):

    服务器包defaultServer --include=usr

  3. 上面的命令创建了 defaultServer.zip我将其复制到我的应用程序目录

  4. 我运行以下命令来推送应用程序:

cf推送应用程序名称-p defaultServer.zip

  • 一切正常,但这次我可以从原始根上下文访问我的应用程序,如下所示:

    http://<appname>.mybluemix.net/<root>/login.jsp

  • 我从你的帖子中看到的主要区别是我的 server.xml包括 war 定义,但我没有web.xml文件。

    这是我的server.xml :

    <server description="new server">

    <!-- Enable features -->
    <featureManager>
    <feature>javaee-7.0</feature>
    <feature>localConnector-1.0</feature>
    </featureManager>

    <!-- This template enables security. To get the full use of all the capabilities, a keystore and user registry are required. -->

    <!-- For the keystore, default keys are generated and stored in a keystore. To provide the keystore password, generate an
    encoded password using bin/securityUtility encode and add it below in the password attribute of the keyStore element.
    Then uncomment the keyStore element. -->
    <!--
    <keyStore password=""/>
    -->

    <!--For a user registry configuration, configure your user registry. For example, configure a basic user registry using the
    basicRegistry element. Specify your own user name below in the name attribute of the user element. For the password,
    generate an encoded password using bin/securityUtility encode and add it in the password attribute of the user element.
    Then uncomment the user element. -->
    <basicRegistry id="basic" realm="BasicRealm">
    <!-- <user name="yourUserName" password="" /> -->
    </basicRegistry>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>


    <applicationMonitor updateTrigger="mbean"/>

    <webApplication id="HelloJavaWorld" location="HelloJavaWorld.war" name="HelloJavaWorld"/>

    <webApplication id="HelloServlet" location="HelloServlet.war" name="HelloServlet"/>
    </server>

    关于java - IBM bluemix 迁移war 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33213967/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com