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
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
- After running bat file, command prompt gets interrupted to take input from user
- 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
- Once gets started you should see below screenshot
- 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
- To deploy war/ear application into this server, click “Applications”
- And then click “Deploy” button
- Click “choose file” and browse for the war/ear application
- Click “OK” to deploy into the server
- Your war deployed successfully and its ready to be tested
- To stop the default domain, Run this command
- Stop-domain domain1
- You should below screen, after successfully stopping the server
- Issue “exit” command to close the command prompt
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”
- Open command prompt and change the directory to “D:\glassfish-4.1\bin”
- Run asadmin bat file i.e.; asadmin
- After running bat file, command prompt gets interrupted to take input from user
- 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
- Once gets started you should see below screenshot
- 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 !!