users@glassfish.java.net

Re: Compiling JSP is slow on v3

From: Dominik Dorn <dominik.dorn_at_gmail.com>
Date: Wed, 8 Sep 2010 21:02:52 +0200

Glassfish v3 is osgi based.
This means, that by default it only loads a bare bone
osgi system when started up and waits with loading subsequent stuff
( like
 - the security manager for webapps,
 - servlet stuff,
 - jsp compiler,
 - mojarra for jsf,
 - weld + ejb scanning
 - jersey for jax-rs
 etc.
)
until the first request to a webapp requiring such a feature is made.

After that first request is made, all the modules required for that
feature are loaded and you will experience a much "faster" compilation.

Precompiling JSPs only helps partial as glassfish still has to load
the jsp handler/compiler _even if the JSPs are precompiled_.

But those things are only a issue (imo not a problem) in a
development environment and also only on first startup of the application
server. In a production environment you're probably are the first visitor after
a server restart just to check "if it worked", so again, its only affecting the
developer and not the regular user.


So how speeding up development of jsp applications in Glassfish v3?
==========================================

For JSF/JSP development I would recommend using "exploded" web-archives instead
of .war because you can then only update that specific JSP/JSF-View
instead of redeploying the whole application as it is made when
updating the war in the autodeploy folder.

If you're using the exploded version, I would also recommend using
dynamic reloading with the /.reload file which reloads your app quite
fast (depending on the size of the application)

I'm using maven and usually work with exploded archives and preventing
test-execution on deploying. My command line usually looks like this
(being skriptum the finalName in the pom's configuration)

# first time deployment
mvn clean compile package war:exploded -Dmaven.test.skip=true &&
asadmin deploy --contextpath / target/skriptum

# subsequent deployments
mvn clean compile package war:exploded -Dmaven.test.skip=true && touch
target/skriptum/.reload

After a few reloadings (20+, depending on application size) you will
run out of permgen space and have to kill glassfish. To get started
again, you'll have to
remove some stuff, as you would have problems on deployments after
server restart. For this I created an alias like this (you have to
replace your path to glassfish)

alias gf-clean='rm
/home/domdorn/tmp/glassfish/glassfishv3/glassfish/domains/domain1/generated/*
/home/domdorn/tmp/glassfish/glassfishv3/glassfish/domains/domain1/osgi-cache/*
/home/domdorn/tmp/glassfish/glassfishv3/glassfish/domains/domain1/logs/*
-R'




For updating JSF-Views/JSPs I simply tell IntelliJ Idea to use the
exploded folder
and press CTRL+F9 when I want to "deploy" the page again. This works
good for JSPs/JSFs xhtml, but if you have servlets/jsf beans you have
to use the command for subsequent deployments mentioned above.


I hope this helps.

Dominik


-- 
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn
Tausche Deine Lernunterlagen auf http://www.studyguru.eu !