Back to Basics – How to Deploy an Application on Payara Server / GlassFish 4.1

Uncategorized
No Image

This is Part 2 of our Payara Server – Back to Basics series, see Part 1 – Installing Payara Server on Ubuntu here.


In order for a web application to run, it must be first deployed on an application server such as Payara Server. Deployment in the context of web applications is the act of installing the application on a server. It allows requests to be handled and so on. This guide will provide you with a few different ways to get your application running.

Note: There is an updated version of this blog available to Deploy an Application on Payara Server 5.

If you’re currently on GlassFish and want to try deploying an application to Payara Server, migrating is relatively painless! Check out our migration guide:
{{cta(‘3382707d-3c20-4768-8acd-0a5b78c43d95′,’justifycenter’)}}

Setup

1) For simplicity, this demonstration will be using a sample application called hello.war which can be downloaded from:https://glassfish.dev.java.net/downloads/quickstart/hello.war
2) Place your application or the hello application into a directory of your choosing. Lets refer to this directory as sample-dir
3) Before you begin to deploy any application, at least one Payara Server / GlassFish domain must be started. For guidance on how to do this refer to my previous GlassFish Back to Basics blog at http://www.payara.co/installing-glassfish-on-ubuntu 

 

Deploying an Application from the Command Line

1) Use the asadmin deploy command in your shell box. The form of the command is as follows:

install-directory/bin/asadmin deploy sample-dir/war-name

(install-directory is where your Payara Server / GlassFish is installed) 

 

Screen Shot 2019-05-20 at 8.05.07 AM


 

2) To list the deployed application, use the list-applications command as shown below

 

Screen Shot 2019-05-20 at 8.05.37 AM


 

3) To access the application, navigate to http://localhost:8080/hello to see this page:

 

 

Screen Shot 2019-05-20 at 8.06.20 AMEnter your name in the space given and click submit. The application should return you with a favorable response!

 

Screen Shot 2019-05-20 at 8.06.42 AM

 

Undeploying an Application from the Command Line

1) In this case, use the undeploy command as similarly done for deploy:

 

install-directory/bin/asadmin undeploy war-name

 

However, for war-name, omit the .war extension and refer to it by just the name. For example:

 

Screen Shot 2019-05-20 at 8.07.13 AM

 

Deploying an Application from the Administration Console

1) Access the administration console by navigating to http://localhost:4848 (make sure a domain is running beforehand)

 

2) Click on applications under the heading common tasks on the left side of the page.

 

3) Any deployed applications are listed here. Since there are none right now, click on deploy.

 

4) The current display should be the deploy applications or modules page. There are two options available. Select Packaged File to be Uploaded to the Server and click browse. Navigate to where your application is located. Select the file and click open. You should be returned to the same page with some settings listed below. If the steps have been done correctly, it should look like this:

 

Screen Shot 2019-05-20 at 8.07.37 AM

 

 

5) Change any settings if needed otherwise accept the default settings and click ok to be returned to the applications page. Your application should now be listed.6) Finally, under the action tab click launch. The default URL for the application is http://localhost:8080/appname  In this case http://localhost:8080/hello

Undeploying an Application from the Administration Console

1) Go to http://localhost:4848

 

2) Click on applications under the common tasks header

 

3) Select the check box next to the application you wish to undeploy

 

4) To undeploy the application – click undeploy. To disable the application – click disable.

 

Deploying an Application Automatically

1) Make sure a domain is atleast running. Copy your application to theinstall-directory/glassfish/domains/domain-name/autodeploy directory. The default domain is called domain1.Doing the same step in terminal is shown as follows:

 

Screen Shot 2019-05-20 at 8.07.58 AM

 

2) Finally go to http://localhost:8080/hello to access your application.

 

Undeploy an Application Automatically

1) Simply delete the application file from the directory. In terminal :

 

Screen Shot 2019-05-20 at 8.08.17 AM

 

And that’s all! Want a complete, step-by-step guide to getting started with the Payara Platform? We’ve got an online and printable guide for that: 

{{cta(‘7a5cce4a-1c08-4a04-a259-3c85c1934c9d’,’justifycenter’)}}

{{cta(‘4c7626f5-1e53-418e-90c8-add6e4af19c9’)}}

 

 

 

Comments (13)

Post a comment

Your email address will not be published. Required fields are marked *

Payara needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Legal & Privacy Policy.

  1. Stephan Rudolph

    Very clear and well structured article. Great job!
    When you investigated the different ways of deploying an application on glassfish, did you ever try to do it by Maven?
    In general, is there a Maven plug-in for deployment available for glassfish like this: https://docs.oracle.com/middleware/1212/wls/WLPRG/maven.htm#WLPRG591
    I would be glad about your news very much.
    Kind regards
    Stephan

    1. Andrew Pielage

      Hi Stephan,

      There is a Maven plug-in for GlassFish, though it’s rather old and I don’t think it has been updated in quite a while – A quick Google search seems to indicate that it still works with GlassFish 4 and Maven 3 though.

      You can find the documentation and usage instructions here: https://maven-glassfish-plugin.java.net/

      Thanks,
      Andrew

    2. Ondrej Mihályi

      Hi Stephan,

      You may use official Glassfish maven plugin to deploy to Payara. It requires a local Glassfish/Payara installation so it is not convenient for remote deployments.

      A maven plugin from Cargo project also works, even in remote deployments and the project is more active. You can see an example how to configure it in this github repository, in Payara maven profile: https://github.com/arun-gupta/couchbase-javaee/blob/master/pom.xml

      Cheers,
      Ondrej

      Cargo project: https://codehaus-cargo.github.io/cargo/Maven2+plugin.html

  2. Ashley Bye

    I have just installed payara4.1 and am trying to access the web admin console. After enabling secure admin (asadmin enable-secure-admin) as instructed to be able to proceed with login, I am now asked for a certificate for 2-way authentication. What certificate do I need to present that the server will accept? All those that I have tried result in access being denied.

    1. Andrew Pielage

      Hi Ashley,

      I don’t quite understand the problem you’re having. Are you just trying to access the administration console?

      When you enable secure admin, by default Payara and GlassFish will secure themselves using a generated certificate called “s1as” for the DAS, and another called “glassfish-instance” for all other instances.

      When you try to access the admin console with secure admin enabled, you will be redirected to HTTPS, and your browser will throw a warning page up complaining that it doesn’t recognise the generated certificate (because it isn’t trusted). If you ignore the warning and continue on, it should load the login page.

      I can’t think of a situation off-hand where it would request *you* to provide a certificate to it.

      Thanks,
      Andrew

  3. Edwin Kun

    Hi, how can i make payara autostart everytime my ubuntu server started? And how can i put payara as an ubuntu service?

    Thanks

    1. Ondrej Mihályi

      You may use asadmin create-service command to generate a System-V startup script, which is supported by Ubuntu. For more info, run asadmin help create-service and scroll to Behavior on Linux systems.

      Then configure the service as a usual ubuntu (System-V) service to make it start when Ubuntu starts.

  4. Aris Javier

    How to see the status of the application when doing list-applications command? I have disabled apps that I want to check if they are still disabled or not. Thanks!

    1. Andrew Pielage

      Hi Aris,

      You can use the –long option with the list-applications command to display whether or not deployed applications are enabled or not.

      For example, `asadmin list-applications –long` will display something along the lines of:
      NAME TYPE STATUS
      clusterjsp enabled

      You can find some other useful options using the –help option (asadmin list-applications –help).

      Thanks,
      Andrew

      1. ARIS JAVIER

        Thank you so much! I’ve been looking for this solution in a long time. I always end up using the admin console just to see the status. Thanks again!

  5. Adaileno Brito de Jesus

    The command for undeploy is presented incorrectly on the article:

    Undeploying an application from the command line

    1) In this case, use the undeploy command as similarly done for deploy:

    install-directory/bin/asadmin deploy sample-dir/war-name

    Instead, it should be
    install-directory/bin/asadmin undeploy sample-dir/war-name

  6. Chandresh Patel

    Hi Ahmed,

    I wanted to share my article on automating deployments to Payara – https://flexagon.com/2018/04/automate-deployments-to-payara-application-server. This is basically done using FlexDeploy.

    Thanks,
    Chandresh Patel

  7. Caleb Momanyi

    What is the procedure for deploying a web module to a specific virtual server? Is there a command line argument for that.

Related Posts

Community_Announcement 4 minutes
Uncategorized

Leading the Way: Payara Platform Community 7 Beta Now Fully Jakarta EE 11 Certified

We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]

What Is a Java Application Server? A Short Guide 6 minutes
Jakarta EE

What Is a Java Application Server? A Short Guide

Enterprise Java applications power global commerce, healthcare, government and countless other industries. These systems must be scalable, secure and […]

10 minutes
Uncategorized

Java’s 30th Anniversary: A Celebration of Legacy, Evolution and Community

May 2025 marks a monumental milestone in software development: Java turns 30. The impact of this language on the […]