Thursday, October 17, 2013

How to create Spring MVC project using Maven and Eclipse


This blog will show you how quickly you can  create a Spring MVC project and get it up and running, using the Maven archetype called spring-mvc-archetype.

Note: First You should verify that the Maven Integration for FTP is already installed in your eclipse, If not first installed and then create a new project.

Steps :
  • In Eclipse IDE, Goto  File > New > Project
  • Select Maven > Maven Project and click Next.
  • Make sure you don’t check the option Create a simple project (skip archetype selection), and click Next. In the next screen,
  • Select Catalog as All Catalogs, Archetype as spring-mvc into the Filter  and select maven-archetype-webapp in the artifact list as shown below :

 

In case, If you don't see the above artifact in your Archtype then Click on "Add Archetype" and Add :
    • Archetype Group Id: co.ntier
    • Archetype Artifact Id: spring-mvc-archetype
    • Archetype Version: 1.0.2
    • Repository URL: http://maven-repository.com/artifact/co.ntier/spring-mvc-archetype/1.0.2\
     
Click Next and Enter Group Id (e.g. Test), Artifact Id (e.g. Test), Version (e.g. 1.0) and Package (com.waheed.test), as shown below :

Click Finish.Finally you have a project structure looks like below:                         

 

Thursday, July 25, 2013

How to do JVM Remote debugging via SSH

Last week I was getting one issue which was difficult to debug as the product was on EC2 instance. We were wasting lot of time as It was difficult to test and check the actual cause of issue.  Later I decided to attach the Eclipse debugger to my target JVM which is running on some different(EC2 instance) machine with the help of PuTTy ( PuTTY is an SSH and telnet client).

Lets start with the steps :

1. Make sure your target JVM is started with these args:
        -agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=n
2. Create an SSH session into your PuTTy.
      Open Putty, Add :
        -- IP Address : "YOUR_TARGET_JVM_ADDRESS"
        -- PORT : 22
        -- Saved Sessions : your session name
        -- Choose 'SSH' radio button and Save it.
  
       

  
3. After saving your server detail, in the same putty :
     -- Goto Category -> SSH ->tunnels
     -- source port :7000
     -- Destination : ip:port <eg : 10.0.2.12:8001> 
     -- Click on 'Add' button
     -- Again click on 'session' under category and save it.
     -- Start the session once you are done with above settings by clicking on 'open'  button.
   
 


4 . In Eclipse, Goto Run -> Debug Configuration -> Remote Java Application and Add :
      -- Project : point to your project directory
      -- Choose 'connection type'  as 'Standard (Socket Attach)'
      -- Host : localhost
      -- Port : 7000 (Must be same as source port in PuTTy)
       

   

Now You  are good to go to start with your remote debugging :)

Note : Sometime during Remote Debugging, You might get some error message like "Connection timeout". To fix the issue, Goto : Eclipse - > Windows -> Preferences -> Java ->Debug and set debugger timeout as some higher value.

 Please let me know your comments/feedback, if any.

Friday, May 24, 2013

How to enable convert extension into Mercurial ?

Advanced users of Mercurial can be aided with the use of Mercurial extensions. Extensions allow the integration of powerful new features directly into the Mercurial core. 
 
Built-in help on extensions is available with 'hg help extensions'. To get help about an enabled extension, run 'hg help <extension-name>'.

Convert Extension

The Convert extension converts repositories from other SCMs (or even Mercurial itself) into Mercurial repositories, with options for filtering and renaming. It can also be used to filter Mercurial repositories to get subsets of an existing one.
The current release supports the following repository types as sources:
  • CVS
  • Subversion
  • Git
  • Darcs
  • Monotone
  • Bazaar
  • GNU Arch
  • Mercurial
  • Perforce
Convert extension comes up together with Mercurial. To enable convert extension, add following lines in your configuration file, Edit your $HOME/.hgrcwhich look like:
 
[extensions]
hgext.convert=




Lets begin by downloading the latest revision of the repository. Mercurial will download it from the remote repository with the full history.

[root@localhost Desktop]# hg convert svn://svn.repo.com/frontend/mxlLayer mxl_test
initializing destination mxl_test repository
scanning source...
sorting...
converting...
9 creating new repository for mxl Service layer.
8 * Fixed 500 error while creating tenant
7 * Javadocs added
6 * Renamed MXLLayerLog.xml back to logback.xml
5 1. Change return type of createTenant from long to MXLServiceResponse in TenantController.java
4 Added 3 new Api's:
3 Added target to ignore list
2 Added start/stop functionality.
1 Changed code according to review comments.
0 1.Added test cases for TenanatController Api's:1.CreateTenant 2.GetProtalInfo 3. GetApplications.


We are done! If you cd to the newly created mxl_test directory, you will be entering a fully fledged, history-preserved Mercurial repository, consisting of the exact same files as the Subversion repository.

[root@localhost mxl_test]# hg update # update to pull all repositories.
26 files updated, 0 files merged, 0 files removed, 0 files unresolved

[root@localhost mxl_test]# hg log # All log entry are preserved.
changeset: 9:08614ddd43c7
branch: mxlLayer
tag: tip
user: ankush
date: Fri Dec 28 16:19:17 2012 +0000
summary: 1.Added test cases for TenanatController Api's:1.CreateTenant 2.GetProtalInfo 3. GetApplications.
changeset: 8:c59c6dedf445
branch: mxlLayer
user: pravin
date: Fri Dec 28 13:54:15 2012 +0000
summary: Changed code according to review comments.
changeset: 7:7b863092bf77
branch: mxlLayer
user: abdul
date: Fri Dec 28 09:55:34 2012 +0000
summary: Added start/stop functionality.
changeset: 6:14064cef906d
branch: mxlLayer
user: deepak

date: Thu Dec 27 16:12:38 2012 +0000
summary: Added target to ignore list
changeset: 5:2a450c99b687
branch: mxlLayer
user: pravin
date: Thu Dec 27 15:10:07 2012 +0000
summary: Added 3 new Api's:
changeset: 4:681d8882361e
branch: mxlLayer
user: abdul
date: Thu Dec 27 13:09:46 2012 +0000
summary: 1. Change return type of createTenant from long to MXLServiceResponse in TenantController.java
changeset: 3:dc92af2b2e48
branch: mxlLayer
user: deepak
date: Thu Dec 27 08:54:07 2012 +0000
summary: * Renamed MXLLayerLog.xml back to logback.xml
changeset: 2:628fd78ee782
branch: mxlLayer
user: deepak
date: Thu Dec 27 05:52:43 2012 +0000
summary: * Javadocs added
changeset: 1:7513eadc9761
branch: mxlLayer
user: deepak
date: Wed Dec 26 15:39:08 2012 +0000
summary: * Fixed 500 error while creating tenant
changeset: 0:bc1f1d1f6a30
branch: mxlLayer
user: abdul
date: Wed Dec 26 14:11:55 2012 +0000
summary: creating new repository for mxl Service layer.











How TOPT Works: Generating OTPs Without Internet Connection

Introduction Have you ever wondered how authentication apps like RSA Authenticator generate One-Time Passwords (OTPs) without requiring an i...