Monday Feb 07, 2011

TOTD #155: Run GlassFish in Windows Azure

David Chou blogged about Run Java with GlassFish in Windows Azure ... super! I've been thinking of trying this for sometime and was quite stoked when an initial introduction from Doris and a nudge from me expedited a task pending since past few months. Thanks a lot David for blogging the steps and answering my multiple emails (about 70+ over the past few days :) to help fine tune these steps for the GlassFish community.

This Tip Of The Day (TOTD) will provide detailed steps for running GlassFish in Azure. Lets get started!

  1. Request a free 30-day Windows Azure Pass (or click here). It took me about 15 days between the request and issue of this pass so plan accordingly.
  2. Download and Install the softwares
    1. Download and Install Visual Studio Express.
      1. Install Virtual Clone Drive such that Visual Studio ISO image can be mounted and then installed.
    2. Download and Install Azure SDK and Tools.



      "VCloudService.exe" is the plug-in for Visual Studio and provides integration of Azure tools to Visual Studio. The SDK provides out-of-Visual Studio help so you could do things on the CLI or test the project using Compute and Storage emulator (more on this later).
    3. Install IIS 7.0 on Windows Vista following these instructions.
    4. Make sure to enable "World Wide Web Services", "Application Development Features", ".NET Extensiblity" and "ASP.NET" in Control Panel as shown:

    5. Download JDK 1.6 (latest update) for Windows and install it on a Windows machine.
    6. Download GlassFish 3.1 b40.
  3. Upload installation files to Azure Blob Storage - Upload the GlassFish zip file and JDK installation zip to Azure Blob Storage service. These images will then be used by the Compute Cloud to install JDK and GlassFish during the image initialization.
    1. Using Azure Management Console, create a New Storage Account as shown:


    2. The typical convention is to create multiple containers in Blob Storage and load your application into "apps" container and JDK installer into "java" container. There are several tools that allow you to manage the Azure Storage service such as Neudesic's Azure Storage Explorer and Cerebrata's Cloud Storage Studio. I prefer Cloud Storage Studio because it gave me a nice debug error message when the local Windows machine date/time were too much out of sync with the storage server. However once the error was identified and fixed, Azure Storage Explorer worked as well.

      Note for creating a new account in either of these tools, create a new "Storage Account" using "Azure Management Console", and use "Primary access key" and "Account Name" for account credentials



      This is the same access key specified in the project configuration later. I used GlassFish 3.1 build 40 and installed JDK locally on my machine, made a zip, and then uploaded in the storage. Another option is to silent install JDK.

      Here are snapshots from Azure Storage Explorer after the files are uploaded to Azure Blob Storage:



      Make sure to select "HTTPS" check box when the connection is created. And now Cloud Storage Studio snapshot ...


  4. Create the Visual Studio project
    1. Start Visual Studio using Administrator privileges. This will ensure that service package created later can be deployed to Azure Compute Emulator (used for testing in the local environment) from within the IDE.
    2. Select "File", "New Project ..." and create a cloud-based project by selecting/entering the values as shown:



      and click on "OK".
    3. Create a new worker role as:



      Select "Worker Role", click ">", edit the name to "GlassFishWorker", and click on "OK".
    4. Extract MinimalJavaWorkerRole.zip (from Mario Kosmiska's article) and copy the following files:
      • lib\\ICSharpCode.SharpZipLib.dll
      • Run.cmd
      • Launch.ps1

        from "JettyWorkerRole" to this newly created solution. The updated directory structure looks like:

         
    5. Make sure to save "Launch.ps1" and "Run.cmd" using "Save As...", "Save with encoding" and selecting "Western European (Windows) - Codepage 1252" instead of the default "UTF-8".
    6. Change the properties of the copied files such that these files are copied to output directories for compilation and packaging. In Solution Explorer, right-click on each file and select "Properties" and change the value from "Do not copy" to "Copy always" as shown below:

    7. Edit "Launch.ps1", keep the two pre-defined functions as is and change the text as shown below:

      $connection_string =
      'DefaultEndpointsProtocol=http;AccountName=YOUR-STORAGE;AccountKey=YOUR-KEY'
      
      # JDK
      $jdk = 'jdk1.6.0_23.zip'
      download_from_storage 'java' $jdk $connection_string (Get-Location).Path
      unzip ((Get-Location).Path + "\\" + $jdk) (Get-Location).Path
      
      # GlassFish
      $glassfish = 'glassfish-3.1-b40.zip'
      download_from_storage 'apps' $glassfish $connection_string (Get-Location).Path
      unzip ((Get-Location).Path + "\\" + $glassfish) (Get-Location).Path
      
      # Launch GlassFish
      .\\jdk1.6.0_23\\bin\\java `-jar
      .\\glassfish3\\glassfish\\modules\\admin-cli.jar start-domain --verbose
      
      

      "jdk1.6.0_23.zip" is the name of zipped directory JDK 6 installation uploaded to Azure Blob Storage and similarly "glassfish-3.1-b40.zip" is name of the zip file for your GlassFish 3.1. The latest build of GlassFish 3.1 can always be downloaded from here.
    8. Edit "ServiceDefinition.csdef" to change the service definition and add the following fragment:
      <Startup>
         <Task commandLine="Run.cmd" executionContext="limited"taskType="background" />
      </Startup>
      <Endpoints>
         <InputEndpoint name="Http_Listener_1" protocol="tcp" port="80" localPort="8080" />
         <InputEndpoint name="Http_Listener_2" protocol="tcp" port="8181" localPort="8181" />
         <InputEndpoint name="Http_Listener_3" protocol="tcp" port="4848" localPort="4848" />
         <InputEndpoint name="JMX_Connector_Port" protocol="tcp" port="8686" localPort="8686" />
         <InputEndpoint name="Remote_Debug_Port" protocol="tcp" port="9009" localPort="9009" />
      </Endpoints>
      
      
      as shown below:



      Notice the external "port" for "Http_Listener_1" is 80 and "localPort" is 8080. This ensures that public requests can be received without specifying the port number (80 being the default) and then internally it is routed to port 8080 which is where GlassFish is running anyway. For all others, the same port is exposed.
  5. Deploy the project from Visual Studio, complete steps are described here and the relevant ones are captured below:
    1. Create a new Hosted Service using Azure Management Console by clicking on "New Hosted Service" and entering the details as shown below:



      and click on "OK". If you recall, we set the external port to be 80 and redirecting to local port 8080. With this setup, your requests will be received at "glassfish-service.cloudapp.net:80" or "glassfish-service.cloudapp.net" and redirected to GlassFish 3.1 b40 running on the provisioned instance. Choose the service name carefully as that becomes the URL of your deployed service.
    2. In Solution Explorer, right-click on the project and choose "Publish ..."



      The default operating system provisioned is "Windows Server 2008 SP2" and can be configured by editing "osFamily" and "osVersion" attributes in ServiceConfiguration.csdef. For example changing "osFamily" to "2" will use "Windows Server 2008 R2".
    3. Specify the Credentials as shown below:



      and click on "OK".
    4. Click on "Copy the full path" and then copy the certificate to "Management Certificates" section of the Management Portal.
    5. Select the "production" environment as shown below:



      and click on "OK".
      1. Optionally, you can configure Remote Desktop Connection in case you want to look at the provisioned system later. Here is how the configuration looks like:



        More details about the configuration are described here. Some clarifications on this step ...
        1. The password must contain a mix of lower-case letters, upper-case letters, and numbers or symbols otherwise will not accept it. Just a red icon appears to the right with no indication of the error message.
        2. Certificate Export
          1. After the certificate is created, click on "View ...", "Details" tab, "Copy to file ..." button to copy the generated certificate to a file. This certificate need to be imported in Management Portal.
          2. Make sure to select "Yes, export the private key".
          3. Select "Delete the private key if the export is successful".
        3. Upload this certificate to Management Portal (before publishing the project) as explained in "To upload a certificate using the management portal" here.

          How I could not get this configured successfully and kept getting the error:
          There was no endpoint listening at https://management.core.windows.net/SUBSCRIPTION-ID/services/hostedservices/glassfish-service/deploymentslots/Production
          that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
          
    6. The "Windows Azure Activity Log" displays log as the project is deployed to Azure. The following is displayed once the project is successfully deployed:



      Now you can access the "Website URL" to see:



      And web-based Admin Console is seen as:


This GlassFish instance is the default installation. What would you like to do with it - hack it, break it, deploy apps to it, something else ? :-) I can just right-click in my Visual Studio project and deploy this instance again!

Once again, many many thanks to David Chou for helping me through these steps!

Some TODOs for the future blog entries ...

  1. Create a Java EE 6 application using NetBeans and remote deploy it to this instance.
  2. Try out this installation locally using Azure Compute Emulator and Storage Emulator.
  3. Try debugging Launch.ps1 scripts using Power Shell.
  4. Use JPA to access data in SQL Azure.
  5. Debug SOAPAction error in Remote Desktop Connection.
  6. Windows Azure VM Role feature for JDK installation.
  7. Is ServiceConfiguration extensible ? I'd love to have an attribute in this file take care of JDK/GlassFish installation.
  8. GlassFish 3.1 clustering integrated with Azure Clustering and Load Balancing.

Which one are you going to author ? :-)

Technorati: totd glassfish javaee6 microsoft windows azure cloud

Tuesday Apr 01, 2008

BizTalk Services SDK, GlassFish and Metro


Microsoft BizTalk R11 CTP was released last week and now contains a sample that is based on GlassFish, Metro and NetBeans. Even though today is April 1st, this is not intended to be an April Fool's Day joke. Read more about the sample in this blog entry. The relevant bits from the entry are quoted below:

The sample shows how to use the BizTalk Services Identity Security Token Service (STS) to secure the communication between a Java client and a Java service providing federated authentication and claims-based authorization. The sample, which you can find in ./Samples/OtherPlatforms/StandaloneAccessControl/JavaEE5 once you installed the SDK, is a pure Java sample not requiring any of our bits on either the service or client side. The interaction with our services is purely happening on the wire.

The Metro team over at Sun Microsystems has made a very significant contribution to making this all work. Before we started making changes to accommodate Java, there would have been very little hope for anyone to get this seemingly simple scenario to work. We had to make quite a few changes even though our service did follow the specs.

As a result of this collaboration, Metro 1.2 is going to be a better and more interoperable release for the Sun's customers and the greater Java community and BizTalk Services as well as our future identity products will be better and more interoperable, too. Win-Win. Thank you, Sun.

Thank you Microsoft for adding this sample to the BizTalk Services SDK.

Metro team demonstrated a similar demo at JavaOne 2007. The demo shows how an Excel 2007 client can invoke a secure and reliable endpoint deployed on GlassFish. The entire source code for the sample, along with instructions to build, are available here.

This is possible today because of our participation in previous 6 plugfests (Mar 2008, Nov 2007, Jul 2007, Oct 2006, Mar 2006, Nov 2005) hosted by Microsoft.

Technorati: glassfish netbeans metro webservices biztalk microsoft interoperability

Tuesday Jul 31, 2007

Transcript of Sun and Microsoft Interoperability Exchange Forum

A complete transcript of the Sun/Microsoft Expert Exchange Forum is now available. And if you still have questions, feel free to post them to users@metro or Metro Forum.

Try 3 things today:

  1. Download GlassFish V2.
  2. Develop and Deploy a Reliable Web service using NetBeans IDE following this screencast (complete list).
  3. Read more details about Project Tango in this 26-page article.

Technorati: wsit metro webservices glassfish netbeans sun microsoft interoperability

Wednesday Jul 18, 2007

Fourth Microsoft Interop Plugfest Report

As reported earlier, Metro team from Sun participated in the fourth (third, second, first) Microsoft Interop Plugfest. Microsoft is working on .NET 3.5 (codename Orcas) and the focus this time was to ensure that there are no regressions with WSIT 1.0. Read Harold's report for more details.

Technorati: webservices metro plugfest glassfish microsoft interoperability

Wednesday Jul 11, 2007

Sun Expert Exchange FREE Forum - Sun and Microsoft Interoperability

Whether you watched Tango in Sun Net Talk or not, you can still participate in Sun Expert Exchange Forum, a FREE forum, asking questions about Sun and Microsoft interoperability. I'll be there, along with Harold Carr, to field all questions on Project Tango. And then there are experts on other topics from Sun as well.

You can read all about Project Tango in this 26-page article.

Technorati: webservices wsit sun microsoft interoperability

Wednesday Jun 27, 2007

Yet Another Microsoft Interop Plugfest

Microsoft announced a 3-day Web services interoperability plugfest from Jul 10-12, 2007. At Sun Microsystems, we love to Tango with Windows Communication Foundation component of .NET 3.0 framework and so we'll be participating using GlassFish V2. This may be the last plugfest before GlassFish V2 is released later this year.

As in earlier events, attendees implement a set of pre-defined scenarios based on WS-\* specs using their Web services stack. They participate with implementation on their laptops and interoperate using their client and Microsoft endpoint and vice versa.

The set of scenarios are based on the following specifications:

  • Basic Messaging Scenarios using protocols: SOAP1.1, SOAP1.2, WS-Addressing 2004/08 and 2005/10, MTOM
  • Message Security Scenarios using WS-Security 1.0, WS-Security 1.1, WS Secure Conversation 2005/02, WS-Trust 2005/02, Username Token Profile (1.0, 1.1), X509 Token Profile (1.0, 1.1), SAML Token Profile (1.0, 1.1), Kerberos Token Profile 1.1.
  • STS - Security Token Service scenarios
  • Reliable Messaging using WS-ReliableMessaging v1.0 (2005/02)
  • Transactions using WS-AtomicTransaction v1.0 (2004/10) and WS-Coordination v1.0 (2004/10)
  • WS-Policy v1.2 (2004/09) and WS-Metadata Exchange (2004/09) are included in several scenarios
  • Windows CardSpace scenarios

Microsoft is also looking for interop testing with pre-release version of .NET Framework 3.5 (codename Orcas) with the following versions of specifications:

  • Message Security Scenarios using WS Secure Conversation v1.3 (2005/12), WS-Trust v1.3 (2005/12)
  • RX - Reliable Messaging using WS-Reliable Messaging v1.1 (2007/02)
  • Transactions using WS-Atomic Transaction v1.1 (2006/06) and WS-Coordination v1.1 (2006/06)
  • WS-Policy v1.5

We run the interop tests regularly with our builds. The results for Tango M5 milestone build shows details for each technology.

Microsoft still need to work out some kinks before the real work can begin:

  • The plugfest schedule still seem to be dated March
  • Not all the scenarios and endpoints as mentioned in the announcement are available
  • Invite logistics page is giving a 404
  • Not all the endpoints are up, atleast RM endpoints are down. Anyway, the endpoints have been down at multiple instances (here, here, here, here and probably other times too!).

But we are still going to participate :) Sun's participation in the previous plugfests can be followed here.

Technorati: webservices wsit plugfest glassfish microsoft interoperability

Monday Apr 23, 2007

Resolved Vista Upgrade Error 80070103

Follow up from here.

After getting bounced around between Microsoft Tech Support and MSDN Tech Support (seem to be separate entities) and collecting almost 5 different toll-free numbers for them, I finally resolved the error with help from a very talented and patient MSDN Tech Support professional.

Basically, the machine had two partitions - one using Windows XP and other Linux. And somehow the Linux partition was coming out as the primary active partition. So every time I was trying to install Vista, whether from within XP or boot from DVD, it was trying to look for an empty space on this partition. And of course it was not able to find any space because this file system is not NTFS. Now when I look at the error message again, it makes sense. But can't the installation process find out that there are multiple partitions, one of them using NTFS, and then provide that information ?

With tech support help, I resolved the issue by deleting and formatting both the partitions. Another way to resolve this was to set Windows XP as the active partition following these instructions.

I almost lost faith in Microsoft Tech Support but this one talented individual helped me restore it.

Technorati: windows Vista XP microsoft

Saturday Feb 03, 2007

Vista, GlassFish and WSIT

During this week, first Windows Vista, then GlassFish v2 M4 and finally JAX-WS 2.1 Final were released. WSIT, using JAX-WS extension points, provides a bridge between the Vista and GlassFish releases by enabling interoperability between the Web services hosted on two platforms. This is the result of endless testing we have done between Windows Communication Foundation that got shipped with Vista and the Web services stack in GlassFish.

Read all about Sun's participation in Microsoft-hosted interoperability plug-fests. Download it here and let us know how it works for you.

Technorati: Vista GlassFish WSIT Microsoft Sun

Friday Feb 02, 2007

Sun understands WS-\* very well!!!

Thanks to Robin Wilton for the link.

Read more about how Sun and Microsoft achieved product-level interoperability between GlassFish and Windows Vista. A quote from the article ...

"as these two teams worked together to bring about some calm in the turbulent seas of Web services, they found that engineering knows no prejudice. The result, three years later, is Sun’s Web Services Integration Technology, and Microsoft has called it the best implementation of the WS-\* standards outside of its own."

I'm proud to be part of WSIT team since it's inception. This is a great start to the weekend!

Technorati: WSIT GlassFish Web services Sun Microsoft

Friday Dec 29, 2006

Scary advertisement

One scary advertisement of Microsoft Live Meeting

Technorati: advertisement microsoft livemeeting apntatube

About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today