Click here to Skip to main content
Click here to Skip to main content
Go to top

ASP.NET Time Tracker Starter Kit Port to Linux using Mainsoft's Grasshopper

, 25 Apr 2007
Rate this:
Please Sign up or sign in to vote.
Race To Linux - How to port a Visual Studio .NET web application to the J2EE Framework on Linux

Introduction

For the Race to Linux, I decided to use Mainsoft's Visual Mainwin for J2EE (Grasshopper) to port the ASP.NET Starter Kits Time Tracker Web Application. I downloaded the Starter Kit files from the ASP.NET Starter Kits site, then opened up Visual Studio, installed Grasshopper (which installs Apache Tomcat 5), and right-clicked on 'Generate J2EE Project'. Is this all you need to do? Not quite...

Methodology

Grasshopper provides a mechanism to convert C# and VB.NET Visual Studio projects into Java byte-code to form a J2EE application. Basically, the .NET Framework namespaces (System, System.Data, etc.) have been re-written into Java JAR assemblies, much like what the Mono Project did. The Mainwin deployment package outputs a WAR archive for installation on the J2EE application server. A good portion of the J2EE class ibrary mirrors what is provided by the .NET Framework (or is this the other way around?). As long as the same namespaces, classes and methods exist in the Mainwin Framework, a C# or Visual Basic programmer can port their application into a J2EE application. My approach was to get familiar with the C# source code, generate the J2EE project, find out what wasn't supported by the Mainwin Framework, debug aggressively, test the ported user functionality using real-world QA approaches, and test the deployment packages on the application server.

I tested the web application with FireFox 1.0.4 and Internet Explorer 6. The application server I tested on was Apache Tomcat 5.0.28 running on Debian Linux 2.4.18.

Here is the order in which I developed the ported application:

  1. Generate the J2EE Project
  2. Fix compile-time errors
  3. Rebuild the J2EE project
  4. Test the functionality of the web application until it breaks
  5. Debug and fix the discovered issues
  6. Rebuild and create the deployment package

Challenges

  1. The chart image didn't work due to a problem the Mainwin Java compiler was having with the url string concatenating using '+' and then a line break. I put the string onto one line (like the .NET and Java compilers do), and this did the trick.
  2. The JDBC jar files were not in the proper Tomcat directory by default, so I got an 'error connecting to socket' message when trying to save my user registration data. Copying the jar files to the Tomcat common/lib directory provided Tomcat with the necessary drivers.
  3. The System.DirectoryServices and System.Drawing assemblies needed corresponding J2EE-compliant Java assemblies. These references threw errors on J2EE compilation.
  4. Validation on the Project Category abbreviation textbox didn't work, so I applied a workaround: a maxlength attribute to match the database schema. I did this rather than fix the validation code for the sake of speed. I will update my blog with the fix at a later date.
  5. Some IDE-specific errors, such as Mainwin not supporting how Solutions and projects are saved the same way as VS.NET, plaqued my progress.
  6. Some unsupported web.config keys actually threw compile errors.

My Race To Linux Blog

You can see more play-by-play details of this porting project here.

Configuring The Linux Server/Installing The Required Packages

Downloading and installing SuSE Linux 9.2 packages:
Open the YaST Control Center and choose Install and Remove Software, which opens the SuSE Package Manager.

Install the following packages. Use the search button to find them:

  • java-1_4_2-sun
  • java-1_4_2-sun-devel
  • java-1_4_2-sun-jdbc
  • tomcat5
  • tomcat5-admin-webapps
  • tomcat5-webapps

Be sure to install all the dependencies YaST2 recommends.

After installing the packages, restart Tomcat. Open a shell window as root. Type the following command:

/etc/init.d/tomcat restart

When your Linux box is rebooted, Tomcat will start automatically.

Deployment Instructions For Tomcat

  1. Download the MainWin Framework JARs zip file from this article.
  2. Copy the JAR files from the zip to the ${TOMCAT_HOME}/common/lib directory.
  3. Restart Tomcat with the shell command: /etc/init.d/tomcat restart
  4. Download the zip file with the WAR package (Tracker.zip) from this article.
  5. JDBC support for SQL Server 2000 is required by this application, so copy the jar files from the zip into the ${TOMCAT_HOME}/common/lib directory, and restart Tomcat.
  6. Deploy the war file using the Admin console:
    http://{hostname}:{port}/manager/html. Scroll down to the WAR File To Deploy section, and use the Browse button to locate the WAR file you downloaded in this article's zip. Click Deploy, and the application is added to the application list in the Tomcat Web Application Manager. Click the Start link next to the listed application, and the application will be available for browsing.
  7. If connecting to a remote SQL Server, you will need to modify the ConnectionString key in the Web.config file located in the ${TOMCAT_HOME}/webapps/TimeTracker directory. Depending on your server's configuration, you may need to use SQL Server's IP address and its port. (Example: 10.0.10.223:1433). The SQL Server 2000 localhost instance listens on port 1433 by default, but you should check by right-clicking on your database instance in the SQL Manager MMC, }} Properties }} 'Network Configuration', clicking on TCP/IP in the right-hand list, and selecting 'Properties'.

Notes:

  • The autoDeploy attribute of the element needs to be set to true in the ${TOMCAT_HOME}/conf/server.xml config file in order for Tomcat to automatically deploy the war file when you copy it to the ${TOMCAT_HOME}/webapps directory and restart Tomcat.
  • For a manual install, copy the WAR file to the ${TOMCAT_HOME}/webapps directory and then restart Tomcat. For more detailed information, from the Apache Jakarta Project Web site, go to the Manager App HOW-TO page. Follow the instructions described under the heading "Deploy A New Application from a Local Path".

Alternate Application Server Deployment Instructions

These application servers will not be used by Code Project to test my application, but I have provided excerpts from Mainsoft's Grasshopper Documentation if you would like to deploy the application yourself, and you are using one of the following application servers.

Deployment Instructions for WebLogic:

  1. Open the WebLogic Server Admin Console at http://{hostname}:{port}/console (e.g. http://localhost:7001/console).
  2. Under your domain name, go to Deployments }} Web Applications Modules.
  3. Click the Deploy a new Web Application Module link.
  4. Locate the application WAR file, and click Target Module.
  5. In the Name field, enter the name of the Web application/service.
  6. Click Deploy.
  7. The console displays the Deploy tab, which lists deployment status and deployment activities for the Web application/service. After a few seconds, the status changes to "Success".
  8. Add the JDBC jars to the WEBLOGIC_CLASSPATH environment variable in the file commEnv.cmd (located at {WebLogic_install_dir}\common\bin). For example, if you copy all of the JARs to a temporary folder on the remote machine, your code may look like this:

    set WEBLOGIC_CLASSPATH=%WEBLOGIC_CLASSPATH%; C:\temp\msbase.jar;
    set WEBLOGIC_CLASSPATH=%WEBLOGIC_CLASSPATH%; C:\temp\mssqlserver.jar;
    set WEBLOGIC_CLASSPATH=%WEBLOGIC_CLASSPATH%; C:\temp\msutil.jar; 

Deployment Instructions for WebSphere:

  1. Open the WebSphere Administrative Console.
  2. Under your node name, go to the Applications }} Enterprise Applications page and click Install to open the installation wizard.
  3. In the Local path text box, enter the path to your WAR file.
  4. In the Context Root text box, enter the required application context root and click Next.
  5. Continue clicking Next until you see the wizard's summary page. Review the installation summary, and if it is correct, click Finish.
  6. Save the configuration.
  7. From the Enterprise Applications page, start your Web application/service by selecting the check box next to it and clicking Start.
  8. Copy the JDBC jar files contained in the zip file to {WebSphere_install_dir}\AppServer\lib

Deployment Instructions for JBoss:

  1. Copy the WAR file of the Web application/service that you want to deploy into the {JBoss_install_dir}\server\{server name}\deploy directory.
  2. Copy the JDBC jar files contained in the zip file to {JBoss_install_dir}\server\{server name}\deploy


License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Mark Cafazzo
Web Developer
Canada Canada
I work at Cyence International, a Canadian software company that develops ASP.NET apps and components for the banking industry. I have been programming in .NET since beta, and also enjoy experimenting with open source software and Linux.

Comments and Discussions

 
SuggestionAn alternative to Mainsoft Grasshopper Pinmembercodeporting22-Jul-12 17:58 
GeneralLotus Notes Sharepoint integration Pinmemberimaginaryplaymate17-Dec-08 1:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 25 Apr 2007
Article Copyright 2005 by Mark Cafazzo
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid