IBM bluemix迁移战争文件

时间:2015-10-19 12:05:58

标签: java eclipse ibm-cloud websphere-liberty

我对IBM Liberty服务器和Bluemix都相对较新。我现有的Web应用程序在本地WebSphere Liberty服务器(版本8.5.5.7)中部署为战争,运行正常,没有任何问题。

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

选项1

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

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

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

通过这些配置,我可以访问部署在本地Liberty服务器中的应用程序,但不能访问 Bluemix。在这里,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>

你们可以对我的问题嗤之以鼻吗?看起来我缺少一些配置。 任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

选项1

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

当您使用选项1时,您的war文件将由Liberty buildpack在内部修改。它将您的war文件重命名为myapp.war并将根上下文放在&#34; /&#34;。

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

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

您不必指定根目录。

选项2

更复杂。我在本地运行一个简单的测试,它工作正常。

这是我做的:

  1. 我将我的Java应用程序从Eclipse部署到Liberty服务器的本地实例
  2. 我运行以下命令来创建zip文件(需要先停止服务器):

    服务器包defaultServer --include = usr

  3. 上面的命令创建了defaultServer.zip并将其复制到我的app目录

  4. 我运行以下命令来推送应用程序:
  5. cf push app-name -p defaultServer.zip

    1. 一切正常,但这次我可以从原始根目录访问我的应用程序,如下所示:

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

    2. 我可以从您的帖子中看到的主要区别是我的server.xml包含了战争定义而我没有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>
      

答案 1 :(得分:0)

@人员Prasanna-Bableshwar

请参阅下面有关使用Application Migration Toolkit的帖子:

How do I move my existing WebSphere application to Liberty on Bluemix?