Glassfish-4.1 Deployment process

Step 1: Download latest Glassfish-4.1 from Glassfish site which describes step-by-step procedure from downloading ZIP file to loading admin console. We will understand these steps further in detail and deploying of war/ear application into server

Step 2: Unzip the ZIP file and keep it in the some suitable place like say “D:\glassfish-4.1”
In the above location, you should see the below folder structure
1_glassfish-4-1_folder_structure

Note: Glassfish-4.1 comes as portable, no separate installation required

Step 3: Browse through “glassfish” folder, which brings pre-configured default domain i.e.; “domain1” with this portable glassfish installation

Step 4: Confirm above steps, which means you have Glassfish-4.1 in your working environment

Deployment Process

There are two ways to deploy war/ear file into Glassfish-4.1

  • Online
  • Offline

Let understand each one detail

Online

    • Open command prompt and change the directory to “D:\glassfish-4.1\bin”
    • Run asadmin bat file i.e.; asadmin
      2_glassfish-4-1_command_prompt
    • After running bat file, command prompt gets interrupted to take input from user
      3_glassfish-4-1_command_prompt_asadmin
    • To start the server, you require a domain to be configured. Default domain i.e.; “domain1” comes pre-configured with this Glassfish-4.1 portable installation
    • Command to start the default domain mode
    • Start-domain domain1
      4_glassfish-4-1_command_prompt_asadmin_start_cmd
    • Once gets started you should see below screenshot
      5_glassfish-4-1_command_prompt_asadmin_start_cmd_success
    • Enter the URL to open Glassfish admin console http://localhost:4848/
    • Username/password not required to enter admin console
    • Hitting above URL into web browser brings admin console
      6_glassfish-4-1_admin_console_home_page
    • To deploy war/ear application into this server, click “Applications”
    • And then click “Deploy” button
      7_glassfish-4-1_application_deployment_page
    • Click “choose file” and browse for the war/ear application
      8_glassfish-4-1_application_war_deployment
    • Click “OK” to deploy into the server
      9_glassfish-4-1_application_war_deployment_success
    • Your war deployed successfully and its ready to be tested
    • To stop the default domain, Run this command
    • Stop-domain domain1
      10_glassfish-4-1_command_prompt_asadmin_stop_cmd
    • You should below screen, after successfully stopping the server
      11_glassfish-4-1_command_prompt_asadmin_stop_cmd_success
    • Issue “exit” command to close the command prompt
      12_glassfish-4-1_command_prompt_asadmin_exit

 

 

 Offline

In offline mode, you have to copy the war file into the autodeploy folder and needs to start the server. Let us understand it step-by-step

  • Copy(ctrl+c) the war file from application target folder
  • Paste (ctrl+v) it into the location “D:\glassfish-4.1\glassfish\domains\domain1\autodeploy”
    13_glassfish-4-1_war_autodeploy_folder
  • Open command prompt and change the directory to “D:\glassfish-4.1\bin”
  • Run asadmin bat file i.e.; asadmin
    2_glassfish-4-1_command_prompt
  • After running bat file, command prompt gets interrupted to take input from user
    3_glassfish-4-1_command_prompt_asadmin
  • To start the server, you require a domain to be configured. Default domain i.e.; “domain1” comes pre-configured with this Glassfish-4.1 portable installation
  • Command to start the default domain mode
  • Start-domain domain1
    4_glassfish-4-1_command_prompt_asadmin_start_cmd
  • Once gets started you should see below screenshot
    5_glassfish-4-1_command_prompt_asadmin_start_cmd_success
  • Enter the URL to open Glassfish admin console http://localhost:4848/
  • Click Applications
  • You should see the deployed application under this tab
  • Start testing, rest else remain the same as in the case of Online mode

 

Happy Coding !!
Happy Learning !!

Jersey 2.x web service using @QueryParam annotation
Jersey 2.x web service using @PathParam annotation