Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redeploying Java EE applications immediately

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)). enter image description here

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

like image 958
ustun Avatar asked Oct 14 '11 10:10

ustun


People also ask

How Java applications are deployed?

To deploy your Java Web Start application, first compile the source code, package it as a JAR file, and sign the JAR file. Java Web Start applications are launched by using the Java Network Launch Protocol (JNLP). Hence, you must create a JNLP file to deploy your application.

Where is Java application deployed?

Most Java software nowadays runs only on servers (web servers or app servers). They are typically deployed as WAR or EAR files, which are also ZIP archives containing classes and other resources. These applications then run inside a server component following the Servlet or EJB standards.


1 Answers

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:

Go to the project properties dialog, Compile panel, to turn it on for main source execution as well.

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 or Deploy from the projects' context menu. The incremental deployment happens when your project is already deployed and you click Run again (or use the Run 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 the Run panel that you have selected in your screenshot. Here's my screen shot showing that you need to choose for both application and test execution in the Compile panel drop down and that the default is for test execution only

Compile panel drop down

like image 185
Jonathan Spooner Avatar answered Oct 23 '22 11:10

Jonathan Spooner