war 文件的 IBM bluemix 迁移
IBM bluemix migration of war file
我对 IBM Liberty 服务器和 Bluemix 都比较陌生。我现有的 Web 应用程序作为 war 部署在本地 WebSphere Liberty 服务器(版本 8.5.5.7)中并且 运行 没有任何问题。
然而,当我将 war 文件推送到 IBM Bluemix Liberty 服务器时,真正的问题出现了。我尝试推送本地应用程序的方式有两种。
选项 1
在这里,我将我的应用程序导出为 war,目标运行时作为 IBM 组下的 WebSphere Liberty 服务器,然后使用 cf push <appname> -p <app.war>
上传时没有出现任何错误,但我无法访问具有给定上下文根的应用程序。
喜欢http://<appname>.mybluemix.net/<<root>>/login.jsp
其中 <<appname>>
是应用程序的名称,<<root>>
是 war 文件的名称。
然而,通过这些配置,我能够访问部署在本地 Liberty 服务器中的应用程序,但不能访问
蓝调。此处 Bluemix 无法找到 Web 应用程序的上下文。
选项 2
这里我按照下面的 link link 并尝试了那里提到的所有步骤:
我用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 时,您的 war 文件将由 Liberty buildpack 在内部修改。它将您的 war 文件重命名为 myapp.war 并将根上下文放在“/”中。
因此对于您的情况,您应该能够从以下位置访问您的应用程序:
http://<appname>.mybluemix.net/login.jsp
您不必指定根目录。
选项 2
比较复杂。我 运行 在本地进行了简单的测试,效果很好。
这是我所做的:
我将 Java 应用程序从 Eclipse 部署到 Liberty 服务器的本地实例
我运行创建zip文件的命令如下(需要先停止服务器):
服务器包 defaultServer --include=usr
上面的命令创建了defaultServer.zip
,我把它复制到我的应用程序目录
我运行以下命令推送应用程序:
cf push app-name -p defaultServer.zip
一切正常,但这次我可以从原始根上下文访问我的应用程序,如下所示:
http://<appname>.mybluemix.net/<root>/login.jsp
我从您的 post 中看到的主要区别是我的 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>
@Prasanna-Bableshwar
请参阅下面关于使用应用程序迁移工具包的post:
How do I move my existing WebSphere application to Liberty on Bluemix?
我对 IBM Liberty 服务器和 Bluemix 都比较陌生。我现有的 Web 应用程序作为 war 部署在本地 WebSphere Liberty 服务器(版本 8.5.5.7)中并且 运行 没有任何问题。
然而,当我将 war 文件推送到 IBM Bluemix Liberty 服务器时,真正的问题出现了。我尝试推送本地应用程序的方式有两种。
选项 1
在这里,我将我的应用程序导出为 war,目标运行时作为 IBM 组下的 WebSphere Liberty 服务器,然后使用 cf push <appname> -p <app.war>
上传时没有出现任何错误,但我无法访问具有给定上下文根的应用程序。
喜欢http://<appname>.mybluemix.net/<<root>>/login.jsp
其中 <<appname>>
是应用程序的名称,<<root>>
是 war 文件的名称。
然而,通过这些配置,我能够访问部署在本地 Liberty 服务器中的应用程序,但不能访问 蓝调。此处 Bluemix 无法找到 Web 应用程序的上下文。
选项 2
这里我按照下面的 link link 并尝试了那里提到的所有步骤:
我用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 时,您的 war 文件将由 Liberty buildpack 在内部修改。它将您的 war 文件重命名为 myapp.war 并将根上下文放在“/”中。
因此对于您的情况,您应该能够从以下位置访问您的应用程序:
http://<appname>.mybluemix.net/login.jsp
您不必指定根目录。
选项 2
比较复杂。我 运行 在本地进行了简单的测试,效果很好。
这是我所做的:
我将 Java 应用程序从 Eclipse 部署到 Liberty 服务器的本地实例
我运行创建zip文件的命令如下(需要先停止服务器):
服务器包 defaultServer --include=usr
上面的命令创建了
defaultServer.zip
,我把它复制到我的应用程序目录我运行以下命令推送应用程序:
cf push app-name -p defaultServer.zip
一切正常,但这次我可以从原始根上下文访问我的应用程序,如下所示:
http://<appname>.mybluemix.net/<root>/login.jsp
我从您的 post 中看到的主要区别是我的 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>
@Prasanna-Bableshwar
请参阅下面关于使用应用程序迁移工具包的post:
How do I move my existing WebSphere application to Liberty on Bluemix?