How to deploy in GlassFish 3
There are several ways one could deploy application ( all types, ear, war, jar, car or rar) in GlassFish 3.
Here are the most common ways how you could install your application in glassfish, there are few more apart from these listed below, but we are not going to discuss those.
- Direct copy paste in autodeploy folder.
- Through admin UI
- Admin CLI
Lets discuss each of these briefly
Direct copy and paste in autodeploy folder is the easiest one, because you don't need to know nothing but how to deploy except copy and paste in the "autodeploy" folder. People who has experience in tomcat ( most do , especially students ) would find it very familiar.
Instruction: Copy the desired application in the C:\glassfishv3\glassfish\domains\domain1\autodeploy\ ( may differ depending where you installed GlassFish) directory and you are done for the deployement. Whenever you want to undeploy the application, you can delete the copied archive file from "autodeploy" folder to undeploy. If you don't want to copy paste manually you can use your favirote IDE then write your application archieve file directly into the autodeploy folder. Follow the steps below meant for Eclipse 3.6 ( earlier versions is also the same ).
- Once done with the development , right click on the project and cilck on export command and choose the appropriate archive file.
- Click on the next button , and choose browse to locate the autodeploy folder and click finish. If your server is running this will be picked within seconds and deployed.
The second way but very manual is deploying application through admin ui screen.
- Log in to glassfish at : http://localhost:4848/ (typically) providing the user name and password.
- Click on the applications on the common tasks on left frame of browser and then click on the deploy button to bring in the Deploy Applications or Modules screen.
- Click on the browse button to locate your archive or alternativly you can choose any local packaged file or directory check box to locate your application archieve or directory. Remeber the type of the application is a mandatory field which you have to choose otherwise you can't proceede further.
- Click "Ok" to deploy. Once succesfull, it takes you to application page, there you can see Launch, Redeploy and Restart depending the application type. If you want to undeploy or enable/disable particular application you can do so by selecting the check box and then click the desired button.
The third way and the best way for production system and automation is through admin CLI ( Command Line Interface). Which is a java program, executed through bat file loaded with typical administrator tasks to be executed as commands and located in C:\glassfishv3\glassfish\bin\ ( may differ depending where you installed GlassFish). Two important commands for our scenarios are deploy and undeploy.
Instruction: Double click on the asadmin.bat to bring the admin CLI. You will notice asadmin prompt appears. Which means it is ready to take commands.
- Deploy: Issue "deploy" command at the prompt. It will ask for path as "Enter the value for the path operand>" Enter the path of the application where you have the archieve file ex: C:\Documents and Settings\user\Desktop\my_EJB.jar.
- Undeploy: Issue "undeploy" command and it prompts for the application name as "Enter the value for the name operand>" ex: If you want to undeploy the application we deployed in the last step, enter my_EJB .
There is nothing stops you to mix and match the above three ways to manage your applications.
I could help if you are stuck , do leave comment