1

I am relatively new both to IBM Liberty server and Bluemix. My existing web application was deployed as a war in a local WebSphere Liberty server (version 8.5.5.7) and is running fine without any issue.

However the real problem comes when I am pushing the war file to IBM Bluemix Liberty server. There are 2 ways on how I tried to push my local app.

Option 1

Here I exported my application as a war with target runtime as WebSphere Liberty server under IBM group and then used cf push <appname> -p <app.war>

This does not give me any error while uploading but I am unable to access the application with the given context root.

Like http://<appname>.mybluemix.net/<<root>>/login.jsp where <<appname>> is the name of the app and <<root>> is the name of the war file.

With these configurations however I am able to access the apps deployed in local Liberty server but not in Bluemix. Here Bluemix was not able to find context of the web application .

Option 2

Here I followed the link below link and tried all the steps mentioned over there:

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

I packaged the whole server with war and tried to deploy the entire 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

It seems after uploading the instance crashes and gives the error below in the log:

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}

My server.xml file looks like this :

<?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>

The web.xml is like :

<?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>

Could you guys throw any light on my issues? It looks like I am missing some configurations. Any help would be greatly appreciated.

Community
  • 1
  • 1
Prasanna Bableshwar
  • 207
  • 1
  • 3
  • 11

2 Answers2

0

Option 1

is the simpler one. I believe yours should be working, the problem is you are probably trying to launch the application from the wrong root-context.

When you use option 1 your war file will be modified internally by the Liberty buildpack. It renames your war file to myapp.war and puts the root-context in "/".

So for your situation you should be able to access your application from:

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

You do not have to specify the root.

Option 2

is more complicated. I run a simple test locally and it worked fine.

Here is what I did:

  1. I deployed my Java application from Eclipse to a local instance of Liberty server

  2. I run the following command to create zip file (need to stop server first):

    server package defaultServer --include=usr

  3. The command above created defaultServer.zip and I copied it to my app directory

  4. I run the following command to push the application:

cf push app-name -p defaultServer.zip

  1. Everything worked fine, but this time I can access my application from the original root-context, like this:

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

The main difference I can see from your post is that my server.xml include the war definition and I don't have web.xml files.

Here is my 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>
Community
  • 1
  • 1
Alex da Silva
  • 4,552
  • 2
  • 17
  • 25
0

@Prasanna-Bableshwar

Please see the post below that talks about using the Application Migration Toolkit:

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

Community
  • 1
  • 1
RandalAnders
  • 1,431
  • 9
  • 16