Using hot-deploy with Netbeans and Glassfish

One of the nice features, when you were using Netbeans 7.x and Glassfish 3.x, is the hot-deploy feature.

This means, when you change a class or web-page, after saving the file is compiled (if required) and directly deployed to the deploy-location of your project. This can save a lot of time, because you had not to rebuild the whole project.

Using ant

When you are developing a project with ant, the direct deployment can be done by clicking right on your project and choosing deploy. The hot-deployment feature is enabled if you choose the “deploy-on-save” option within in the project properties.

Using maven

When you are developing a project with maven, the direct deployment is “hidden” behind the “run”option in the context menu. The hot-deployment feature can be also enabled if you choose the “deploy-on-save” option within in the project properties.

Ambiguous Dependency issue

One drawback, and currently the only one I ran into, comes from the way hot-deployment is realized by Netbeans.
Netbeans uses the local compile directory to tell Glassfish where the sources are located. This directory is only cleaned up, when you use the Clean or Clean & Build target. This behavior could lead to the “Ambiguous Dependency” error from CDI. This error means, that the implementation of JSR 346 can’t resolve an injection due to too many possible resolvers.

In my observation this issue comes only up, if you rename a class which implements an interface which is injection somewhere else.



7 Kudos

2 thoughts on “Using hot-deploy with Netbeans and Glassfish

  1. Hi, Peter.

    Do you know how to deploy a Maven project using Netbeans, but WITHOUT run the project? That is, to realize a “deploy only” action.

    Thank you!

    1. Hi Almir,

      thanks for your comment.

      You can instrument Cargo for that.

      It has a maven2/3 plugin that allows you to deploy your artifact directly to a server. You can also start / stop the container.

      I hope this helps


Leave a Reply

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