Just Push a Single Button to Update and Restart New Apps
Cloud Foundry Integration for Eclipse Allows Instant App Deployment
Cloud Foundry is a platform as a service environment for hosting cloud technology and software frameworks. The name Cloud Foundry refers to the software, which is free and open-source and available at CloudFoundry.org, while the site CloudFoundry.com hosts Cloud Foundry software that you can use if you dont want to install it locally.
As of this writing, CloudFoundry.com is in beta and is free for developers to use. So far, the site hasnt announced pricing using the sites services. Recently, Cloud Foundry released an extension for Eclipse called Cloud Foundry Integration Extension for Eclipse that allows developers to deploy Java applications to their Cloud Foundry account right from within Eclipse. eWEEK Labs tried out the Eclipse extension and found it to be an excellent and necessary tool for Java developers using Cloud Foundry.
The first thing I did to get started was to sign up with Cloud Foundry by simply going to the site and registering (which only required an email address and nothing more). Soon, I received an email with my registration information, which included a link to download the command-line tools, as well as a link to instructions for installing the extension in Eclipse.
I purposely skipped the command-line tools, because I was determined to do everything right from within Eclipse, even though I didnt know yet if Id be able to. The email also said that the first thing that I needed to do was to sign in with the command-line tools and change my password. I wondered if Id be able to do that from within Eclipse. (As youll see later, the short answer is that I was indeed able to and didnt need the command-line tools at all.)
Next, I started up the version of Eclipse that I had installed on my computer, which is the current 3.7 Indigo release. However, I only had the Java edition, whereas Cloud Foundry needs the JEE (Java Enterprise Edition) Web tools. I didnt want to download the entire JEE edition of Eclipse, so before proceeding, I installed the additional JEE tools from within Eclipse. I then installed the Cloud Foundry Integration Extension for Eclipse by going to the Eclipse Marketplace right within Eclipse itself and searching for the words Cloud Foundry. The extension appeared in the list and I clicked the Install button. After a couple minutes, the extension installed, and Eclipse restarted.
Next, I had to set up a server. Still inside Eclipse, I followed the instructions the email referred to, which included how to create a new server. There was an option to connect either to a local installation of Cloud Foundry or to a Microcloud, which refers to a local Cloud Foundry running inside a VMware player, or to the remote Cloud Foundry servers that Id registered with already.
Deploying Newly Created Apps a Snap
I chose the Cloud Foundry servers and provided my username and password that Id been given in the introductory email. Then a message box popped up to remind me that I needed to change my password, just as the email said I would have to do. But I was able to do it all from within Eclipse, without even installing the command-line tools.
The next step was to build an actual Web application. I created a new Dynamic Web project in Eclipse, and created a JavaServer Pages (JSP) file called index.jsp, and a servlet file that contained Java code. Neither contained much; the index.jsp file just contained a Hello Cloud Foundry! message with a link called Run Servlet. That link opens the servlet page, which in turn displays a message Hello Cloud Foundry Servlet.
After that, I was pleasantly surprised with the deployment procedure. Typically deploying a Web application in other platforms is a bit of a headache. Tools such as Microsoft Visual Studio include publishing features that are a bit clunky. But here, deployment was a snap. I double-clicked the entry in the Server window for Cloud Foundry, which opened a window containing information about my server (including buttons for connecting, changing password and disconnecting).
I was already connected, so I didnt need to connect again. At the bottom of that window is an Applications tab. I clicked that, which presented me with an empty list box. Then I used the mouse and dragged the project name in the Project Explorer window right onto the list box.
A window opened asking for the application name (you can change it for the remote server, but I chose not to) and the application type (the options are Spring, Lift, Grails and Java Web). I clicked Next, and it wanted a URL that ends with cloudfoundry.com. I put in hellocloudfoundry.cloudfoundry.com.
The application uploaded, but I then saw a message that it couldnt launch because the name hellocloudfoundry was already taken. So I right-clicked the application and deleted it from the server and tried again. I went through the same process, but this time chose the name eweek1.cloudfoundry.com. Then I saw a console open at the bottom showing me details of the application starting up.
But was it really live? I wasnt sure, but there was a link next to the list box with my URL, so I clicked it. A Web browser opened inside Eclipse and, lo and behold, there was my index.jsp rendered inside the browser. But just to be sure, I left Eclipse and went to my Chrome browser and put that same URL in. Sure enough, I was looking at my JSP page Id created earlier.
Just Push a Single Button to Update and Restart New Apps
I clicked the link on the page and realized Id made a mistake in the address of the link. I received a 404 error. So I went back to Eclipse and made the change in my index.jsp file.
Then I wasnt sure how to update my change to the server. But once I discovered it, I found that this was the easiest part of the entire deployment process. Next to the application list is an Update and Restart button. I clicked it, and thats all. With that single click of a button, my updates got uploaded to the server. I didnt have to do anything else. I then refreshed the page in Chrome, did a view-source, and could see my change. Clicking on the link, I saw my Hello Cloud Foundry Servlet message.
By now, things were going extremely well, except there was one feature missing. I saw in the instructions that in the original deployment, if Id chosen a local Microcloud running in a VMware Player, I would have remote debugging capabilities. But that option isnt there when your application is hosted on the CloudFoundry.com Website as was my case.
As a professional Web developer, I know that remote debugging is missing from a lot of platforms, or if its present, it doesnt work well. So we learn to live without it, debugging locally and using raw creativity and sheer brainpower to figure out whats wrong when something doesnt work on the server but does locally. But in this case, I was disappointed to see it missing primarily because of a review I wrote for eWEEK three years ago.
Amazon Web Services has an Eclipse Extension that works very similarly to this Cloud Foundry one. You can create your Java Web application and deploy it to Amazons servers right from within Eclipse. And that extension includes remote debugging.
Nevertheless, I would not use that as a reason to switch away from Cloud Foundry to AWS. Instead, I would recommend using the Cloud Foundry extension, but do your development locally, probably against the free and open-source Tomcat server that you can install on your own machine.
Or you can even install the Micro Cloud Foundry and debug against that, by setting up two servers from within Eclipseone for the local Micro version and one for the remote CloudFoundry.com version. Then, when youre ready to deploy, click that one button I was telling you about, and youll be good to go. It works, and it works well. As a result, I definitely give this product a thumbs-up.