Archive

Create and deploy a stand-alone Java application on IBM Bluemix

Share this post:

I’ve found IBM Bluemix to be very intuitive so far, giving users access to many templates, simple drag-and-drop options and illustrative help. But I wanted to provide some information on deploying a stand-alone Java application because it’s something I was searching for, and I assume others will be looking for the same.

I intend to highlight common pitfalls and recommend potential solutions. I will specifically deal with creating an application from the IBM DevOps Service. Once you are comfortable with this, it would be easy to create from the Bluemix service.

1. You can go to IBM DevOps Services to get started . If you don’t already have an account, you can register at no charge.

Java1

2. Once you have an account, you can create a new project by clicking the Create Project button.

Java2

3. It will take you to the next screen where you can provide the name of your project and specify other options such as the repository and whether you would like this to be a public or private project.. For illustrative purposes, I have chosen the Private option, which will ensure that the code is visible only to you (when you log in) and others you invite to be part of the project. If you don’t choose this option, your codewill b visible to everyone.

4. I have also chosen to use the IBM Rational Jazz software configuration management (SCM) for source control. You can select an SCM of your choice.

Java3

5. You will now have a project created.

Java4

6. As a next step, you can either write your code afresh in this project or you can import an existing project archive or .zip file. To proceed with either of these, you need to click on Edit Code.

Java5

7. For illustrative purposes, I created a simple “Hello World!” application. It is important to note that the code has a do-while loop which never exits. For the stand-alone application to run in Bluemix, the code must never exit.

Java6

8. The next step is to create the script to build the code. In this example, I created an .ant script. You can write in the language of your choice from the options supported in Bluemix. Create a file named build.xml and write the .ant build script.

Java7

9. Next, check in the changes by clicking on the SCM option.

Java8

10. On the next screen, click on Check-in and deliver the code.

Java9

11. You now need to create the build configuration. For this click on Build & Deploy.

Java10

12. Click on the Advanced tab in the Build & Deploy screen that comes up, and then click the Add a Builder button.

Java11

13. In the screen that follows, I chose Ant, since I have an .ant build script. You would choose the option that you need. Also specify the DevOps password and click Save.

Java12

14. Next, click on Add a Stage to create your deployment configuration and environment.

Java13

15. In the deployment configuration screen, the cf command is of importance. It is mandatory to specify the “no route” option for Java stand-alone applications, otherwise the monitoring module and the application deployment will fail. This is because your stand-alone application will not be listening on the VCAP_APP_PORT. The health manager will ping this port to check whether your app is up, so if you aren’t listening, it will terminate the container. Specifying the no-route option will eliminate this error.

16. You might also use your own Java buildpack, in which case you would need to use the -b option of the cf command and specify the URL path of the buildpack. If you don’t specify a buildpack, the Java runtime environment (JRE) from Liberty is taken by default. In this example, I used the default JRE provided by Liberty.

17. Fill in the Application Name field in the deployment configuration.

Java14

18. Now when you save and go back to the Build and Deploy screen, click the Request build button. When the build is complete, it will automatically start the deployment process as well. You can then check the application status at the main Bluemix site.

16. Other applications might be deployed in your space and you may have run out of memory. In this case, you might have to delete the application from Bluemix and redeploy this application. Once deployed, you can start and stop the application from Bluemix.

A successful build will show a log.

Java_

A successful deploy log will look like this:

Java_2

Once deployed, the application can be controlled from Bluemix. The Bluemix screen will display the application status and health, along with the option to start or stop.

Java_3

I hope this short exercise is helpful, and I’m interested to hear about your experiences with developing applications on Bluemix. Please use the comments section below to start the discussion.

More stories

Why we added new map tools to Netcool

I had the opportunity to visit a number of telecommunications clients using IBM Netcool over the last year. We frequently discussed the benefits of have a geographically mapped view of topology. Not just because it was nice “eye candy” in the Network Operations Center (NOC), but because it gives an important geographically-based view of network […]

Continue reading

How to streamline continuous delivery through better auditing

IT managers, does this sound familiar? Just when everything is running smoothly, you encounter the release management process in place for upgrading business applications in the production environment. You get an error notification in one of the workflows running the release management process. It can be especially frustrating when the error is coming from the […]

Continue reading

Want to see the latest from WebSphere Liberty? Join our webcast

We just released the latest release of WebSphere Liberty, 16.0.0.4. It includes many new enhancements to its security, database management and overall performance. Interested in what’s new? Join our webcast on January 11, 2017. Why? Read on. I used to take time to reflect on the year behind me as the calendar year closed out, […]

Continue reading