Vgo Software

Entries in Java (5)

Monday
Sep302013

Deploying Tomcat on Amazon's EC2 Cloud Service

Now that Oracle's released it's JaaS offering, it's time I started posting about different cloud options available to you Java developers out there.  Seeing as Amazon's services have been around as long as anybody's and are very robust at this point, it seems like a good starting point.

This article will be a quick guide to deploying Tomcat on Amazon's cloud.  It's fairly quick and it's also very cheap, even free to follow along and try this on your own if you are interested.  Simply sign up for an account here and don't go over the hours limit, considering you get 750 free hours a month, you should be able to complete this tutorial in plenty of time to avoid hitting the limit.  If you do use an Ubuntu Server image as shown in this tutorial it will cost you something.  It cost me about 26 cents to run through this, take my screenshots, and everything else for this post.  Just make sure you stop your instance after you are done with it.

The first thing you need to do after activating your account is to create an AWS instance.  For the purposes of this tutorial we are going to create a VM of an Ubuntu Server, but any Linux environment will probably follow the same procedure very closely.  The Amazon Linux instances should be available for free.

Amazon Elastic Cloud (EC2) instances can be created inside a Virtual Private Cloud or without a Virtual Private Cloud.  For a production instance you would want to use a VPC for security, for this exercise we are not going to use one.

1. Create Security Group

Once you log in to the AWS management console, the first thing we will want to do is create a Security Group.  From the AWS Management Console, click on the EC2 link which will take you to the EC2 Dashboard.  From there, click on Security Groups from the left navigation pane and then click on the Create Security Group button.

In the dialog that pops up, provide a Name, a Description, and choose No VPC.  Then click on "Yes, Create".

The security group will be created without any rules.  To create the rules you want to add to it, select it from the table of groups you are provided with.  The dialog to add rules will appear in the bottom half of the page.

 In our case we are only going to open port 80.  To do that, choose HTTP under the Create a new rule in the Inbound tab, then provide 0.0.0.0/0 (to allow port 80 access from any IP address) as the source and click on "Add Rule".

Then click "Apply Rule Changes".

 

2.  Create an Instance

Now that we have a security group, we can create our instance.  To do that click on the Instances link in the left navigation panel of the EC2 Dashboard.  This will bring up a dialog to enable the Quickstart Wizard which is what we will use for this exercise.

We will need a Key Pair in order to connect to the instance we create.  If you do not see a Key Pair listed under "Select Existing", choose "Create New", create one, and download it.  Click the Click Launch Wizard radio button, and then choose "Ubuntu Server 13.04" and provide a name.  Then click the "Continue" button.

On the next page of the dialog, click the "Edit Details" button, then on the Security Settings radio button.  This will open a multi-select box where we can pick the security groups, including the one we just created.  Highlight "quicklaunch-1" (for ssh) and "web-security-group" (assuming that's what you named it, for http) and then click "Save details".

After saving the details, click "Launch" to create the instance.  It will take a few minutes to initalize.  In the table of instances we should see our newly created instance.  When its state changes from pending to running, we should be able to move on to the next step.

3.  Installing Tomcat

Now that we have a running instance, let's log into it and deploy tomcat.  Check the box to the left of the row in the table of instances that contains the instance we created.  The click on "Actions" and then "Connect" from the dropdown.

You will need to provide the private key file in order to connect, it should have been downloaded when you created the Key Pair.  Make sure you don't lose this file.  In the dialog that pops up, fill in the path to the private key and then click "Launch SSH Client".

After connecting, we need to install Tomcat.  To do that, issue the following command from the ssh terminal.

sudo apt-get install tomcat7

If you are using the Amazon instance use yum. (sudo yum install tomcat7)  If you use yum to install, you will have to add the webapps package to see anything. (sudo yum install tomcat7-webapps)

Tomcat should install fairly quickly, just take all the defaults for any inputs it requires.

Next, start Tomcat.

sudo /etc/init.d/tomcat7 start

Since Tomcat runs on port 8080 and we would need to run Tomcat as root in order to bind it to port 80, we will redirect port 80 to port 8080 instead by issuing the following command.

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

We should now be able to access Tomcat using the public dns address for our instance.  This is the same server you ssh'd into and you can also find the public dns name under the details of your instance on the EC2 Dashboard page at the bottom of the details pane.

4. Installing the Tomcat Management Webapp

If you want to install the Tomcat Management Webapp issue the following command.

sudo apt-get install tomcat7-admin

In Amazon Linux use yum again (sudo yum install tomcat7-admin-webapps).

You will also have to modify the tomcat-users.xml file in the conf directory.

cd /usr/share/tomcat7/conf

sudo vi tomcat-users.xml

Add a role for the manager-gui and a user that has the role assigned.  Please note that all roles and users are commented out in the orignal file.  A different user name that "tomcat" would probably be safer, but for me, this instance is going away as soon as I am done with the tutorial.

 

After you have saved those changes, restart Tomcat.

sudo /etc/init.d/tomcat7 restart

And that's it, you've successfully deployed Tomcat in the cloud!

Now don't forget to stop that instance from running when you are done with it.

 

Wednesday
Sep252013

Oracle's Java as a Service

I've been in San Francisco at Oracle Open World 2013 for the past few days.  It's been a great conference so far with some interesting sessions, some America's Cup racing, and lots of exhibitors to see.

One of the most interesting items to be announced by Oracle at Open World this year was their new Cloud offerings.  They've been talking a lot about the cloud for the past couple of years but it seems this year they are finally releasing some interesting products based on the cloud.

Not only do they now have an Infrastructure as a Service offering, much like Amzaon's EC2 or Microsoft Azure, but they now have a Database as a Service offering and a Java as a Service offering.

This being a Java-focused blog, the Java as a Service product is what I found most interesting and I was actually able to attend a Hands-On-Lab that demonstrated the service.  The usage is very simple, it basically exposes a managed Weblogic Server for you to deploy to.  If you want to have fine-grained control over the environment, this isn't for you, as the only control you have is what you can accomplish via the Weblogic Management Console and the interface to the JaaS itself.

As far as being able to quickly get a application up there and running, it couldn't be simpler however.  The lab demonstrated 3 different ways to do it, one with an IDE plugin (we used Eclipse, I believe there are others), one via the command line, and one via Maven.  You can also deploy and undeploy using the Weblogic console itself.

Most likely you will need more than a JaaS instance if you wanted to do anything worthwhile, for instance you will probably want a database for your application and you will need to use their DBaaS for that, but it does let you easily deploy and run Java applications (including ADF applications!) to the cloud.

Check it out here!

Tuesday
Feb262013

ADF ConcurrentModificationException Issue Resolved

So, as I am sure you are aware, a ConcurrentModificationException will be thrown when one thread is iterating through a list and another thread modifies that list.  We encountered this exception being thrown in an ADF Search page, using the search panel.  With a particular LOV, everytime a user searched after selecting a value from the LOV, the exception would be thrown (and then the results returned).

After much head-scratching, we found that another field had two different LOVs tied to it and some logic to determine which LOV to show.  The attribute with LOV causing the problem was used in the logic, however, it was not set as a dependency.  Once it was set as a dependency the problem was solved!

You live, you learn.

Monday
Jun202011

Why Apple has won and Oracle and Google have lost

Working in the field of software modernization and being specifically focused a lot of the time on modernizing client/server applications, that is, bringing native applications to the web, I couldn't help but wonder if we haven't come full circle already.  

Many years ago with Sun's release of Java as the write-once, run anywhere answer to every developer's problems, it looked like Java Applets might be the wave of the future.  That never did quite catch on as Sun had hoped.  It was plagued mainly by the practical problem of having a platform that runs on every operating system in the same if not very similar fashion.  Because of this "feature", the platform could be limiting at times.  I believe that this type of limitation and the advance of dynamic HTML, CSS, and the web platform in general led to a huge number of web-based applications and a very small number of Java client applications.

Fast forward from then to now and Apple has taken a lesson from Java and decided early on to do things the "right" way.  Of course, the "right" way means being in control of the hardware platform as well as the software platform.  Because Apple controls the whole environment, "apps" are less likely to break, testing is simplified quite a bit, and even development to some extent is simplified.  The result is the creation of some truly amazing client applications for consumers.

Google's Android is a player, but it is starting to suffer from what Java suffered from.  I am not an Android user, but I have seen the complaints that some applications are only supported by newer versions of the software but some hardware platforms do not support the newer version.  This comes across as an Android problem, but surely Apple has the same problem with their platforms?

For some reason, when I can't get an App for my iphone 3G because it doesn't sport the right hardware, it feels like MY problem for being 3 years behind the technology.  That's probably because it isn't just a hardware compatibility issue, the device itself feels clunky and dated compared to newer versions of the iPhone.  Android hardware is so varied and different that the same comparison really cannot be made unless it is among one manufacturer.

Anyway, my point is that Apple has created this beautiful sandbox where these great apps can be created that use the web, but are not web applications.  They are client/server applications with the server being multi-tiered now.  Just look at the articles that have come out regarding iCloud and the amount of app traffic vs. web traffic.  iOS is really what Java should have been.

We haven't seen the push at the Enterprise level yet.  Most customers want a web application, a more and more sophisticated web application, but still, not native apps.  More and more, however, companies are looking at iPads as tools for their workforce and once that happens, their new apps are going to be native iOS apps.

Now the big question remaining is what is Oracle going to do about it?  Does Java have a chance or has it's time passed?

 

Tuesday
Jun232009

Generate an Java-based Ajax-enabled Web App in 5 Minutes

Over the last couple of years there has been a lot of talk about Ruby on Rails and Grails and how easy it is to use them to quickly build an application. How would you like to be able to have all of that speed of development, but have it in a technology that you already know? If you are familiar with Struts or JSF, you can use Rev to quickly build an application for you. 

Rev is a code generation tool developed by Vgo Software, and it gives you the power to do that. All you need is a database, a JDBC driver (most of the common ones are provided with Rev out of the box), a JDK of version 1.5 or better and Rev. Using Rev you’ll be able to generate a completely functional CRUD application based on the tables that you select. The output can be in a variety of different flavors: JSF, Struts, JSF with AJAX, JDBC, EJB, Hibernate, etc. Rev also generates ANT build scripts for a variety of popular application servers so you can build and deploy your application directly from the tool. 

What good is a CRUD application? It all depends on what type of application you are building. For adding testing data or building some Administration screens for a system, the Rev output may be all you need. If you are building a more complicated system, then maybe the persistence layer is all you need and you can rework most of the UI layer. All of the source code is available for you to modify as you see fit, so whether it is the final application itself or the basis for something bigger you will always have something to start with.

One of the unique features of Rev is the ability to customize the generation. Not only can you easily customize the stylesheet from within Rev, but if you want to go deeper you can customize the templates that Rev uses to generate virtually whatever you’d like. From modifying the JSP pages that get generated to creating a whole new set of templates for a completely different language, you can do it all! In fact, included with Rev is a set of templates for generating a PHP-based application. 

You can download your free trial of Rev at the Vgo Software site. Also, be sure to sign up for the webinar I will be presenting on June 30th at 11:00 a.m. EST. During that webinar I will demonstrate how to use Rev and talk about the various output options.