GlassFish Auto Deployment and Hot Deployment

There are several ways to deploy a GlassFish application. To speed up development/debuging we need a way to instantly deploy web applications. One of the ways is to use hot deployment feature, another lesser known feature is ‘directory deployment’. You simply point GlassFish to your development directory and let it pick up and deploy application from there. No packaging and re-deoploying hassles. The catch is whenever you want to re-deploy your application you just need to ‘touch’ a file called ‘.reload’ which should be present in your web folder.
Following is the command and directory structure you can use.
–|myproj
–|–|src
–|–|web
–|–|–|WEB-INF
–|–|–|–lib
–|–|–|–classes
–|–|–|–web.xml
–|–|.reload

GLASS_FISH_HOME/bin/asadmin deploydir full_path_to_you_web_folder

If you are using Eclipse or NetBeans make sure that they put the class files in web-inf/class folder after compiling.

3 Responses to “GlassFish Auto Deployment and Hot Deployment”

  1. Fangzx Says:

    Thanks for this greate tip! I am tired of Eclipse’s auto redeploying, and I lookup this tip for two days!

    In my practice, dir structure should like this:
    –|myproj
    –|–web
    –|– …
    –|–WEB-INF
    –|–|–lib
    –|–|–classes
    –|–|–web.xml
    –|–|–sun-web.xml
    –.reload

    note: in sun-web.xml, you can define custom context name like this(otherwise the dir name become context name):

  2. Fangzx Says:

    content of sun-web.xml:

    /seamsample2

  3. Mellon Says:

    In windows, how to “touch” a file?
    How to make NetBeans touch the file automaticly after some .java files are changed?

Leave a Reply