Search code examples
web-applicationsglassfishweb-deploymentapplication-server

How to deploy my web application locally?


I am a bit confused with Application Server and deploying my web application on it. Say I have my own server at workplace. I understand how a web server works, I could simply install WAMP or XAMP and start my own web server, SQL server as well.

How do I start an application server? Say I want to start a glassfish server. How do I deploy my application on this web server / application server? This confusion has been a nightmare for me. Please help me bring some clarity around this subject.


Solution

  • I am assuming you are using Windows for this.

    To start GlassFish:

    1. Open a command prompt in your GlassFish home directory (where you unzipped or installed to, something like C:\glassfish4). You should see a "bin" folder in this directory.
    2. Run bin\asadmin start-domain to start GlassFish. You will need to make sure that there is nothing running on ports 4848 or 8080, or you may see unusual behaviour.
    3. Go to http://localhost:4848 to see the admin console starting up

    To Deploy to GlassFish

    1. The easiest way is to use the admin console. Click Applications on the left, then click Deploy. You will need to select the app from your local machine to be deployed. Most other settings can be left as default, but make sure there is a server in the target list.
    2. Using the command line again; in the same directory as before in your command prompt, run bin\asadmin deploy C:\path\to\MyApp.war
    3. Alternatively copy and paste your app to the autodeploy folder in your domain (the default domain is domain1): C:\glassfish4\glassfish\domains\domain1\autodeploy. Once your app is in that folder, GlassFish should handle the rest (providing there are no problems with your app)