I am quite new to Java EE and have been struggling with the slowness of the deployment process, and wonder if I'm doing something wrong. I am experienced with Django where the changes to code immediately occur, and it seems that hot deploying Java EE applications are a bit confusing -- there are multiple things which claim to hot deploy (Glassfish, Eclipse manic hotdeploy, Jetty hotdeploy, JRebel etc.).
My project is a Maven project and I'm using Netbeans to deploy. The site uses Spring, JSF and Hibernate frameworks.
In Netbeans, Deploy on Save, according to the following screenshot seems to be enabled, but clicking/unclicking is not possible since it claims to get the info from my pom.xml (though there is no such field in my pom.xml (only dependencies)).
Now, changes to some files seem to be effective immediately. These include: - JSF files - Static files
Changes to following require deployment: - Any XML file - Any properties file, even localization properties files - Any java file
Changes to those require me to deploy manually and redeploying takes half a minute even though I currently have only 2-3 classes, basically a single user class and an authorization class. The project allows just logins at the moment, and despite this, the compilation takes around a few seconds; and the container (Glassfish) seems to consume around 600 MB of RAM and even gives PermGen errors after a few deployments and I need to kill the java process using Task Manager. (I have read that this is related to garbage collector leaking after each redeploy, and I have even used jhat to generate a profile, but was presented with a list of thousands of classes, my classes, Spring, Hibernate classes etc.)
I have heard about jrebel as well, and tried running it, but it seems that it is not compatible with my Netbeans version (7.0) and even though it seems to run, any modification to any java file still requires a redeploy.
Is there anything I can do to remedy these issues, or is it just normal in Java EE to wait for around 1 minute after each change to any Java file? This issue kills productivity significantly.
Here is my Glassfish output when deploying the application: http://pastebin.com/7FhZ6AVh
I've found neither credible nor official sources but since you have no answers I'd like to point out two things I've discovered.
The first is this FAQ on the NetBeans site describing how to turn on compile on save for a Maven project. It appears that this setting is off by default and only on by default for tests. For convenience:
The second is, and I must stress that I don't quite understand this completely, there seems to be two different ways that NetBeans deploys a Web Application. The first way is an in-place deployment that appears to be the same as deploying a
.war
file to the server manually. The second is an incremental deployment, which if it's anything like incremental compilation it means that when your app is hot-deployed you are only deploying the changed files.The in-place deployment seems to be the default method of deployment when you either click
Run
orDeploy
from the projects' context menu. The incremental deployment happens when your project is already deployed and you clickRun
again (or use theRun
toolbar button).I'd like to point out that the NetBeans FAQ, although on the netbeans.org website is not an official publication. Anyone can create a FAQ and the information can and will become obsolete without revision.
Edit: After a little reflection I've decided that the so called incremental deployment is not a different way of deployment it's just that the second time you
Run
your application it does an incremental deployment.Edit: Notice that the instruction above is pointing you to the
Compile
panel as opposed to theRun
panel that you have selected in your screenshot. Here's my screen shot showing that you need to choosefor both application and test execution
in theCompile
panel drop down and that the default isfor test execution only