User Tools

Site Tools


java:hotdeploymenteclipse

This is an old revision of the document!


The fastest way to make a deployment in eclipse

Although eclipse has a system to deploy applications to the application server of our choice (Tomcat, jboss, Web Sphere, etc.) I think that the system it uses is extremely slow. Other solutions that have appeared (jrebel (commercial), and others are depicted here, here, here and here) involve in some way keeping a synchronization of files between the deployed application and the developed application.

I humbly think that there is a better solution, cheaper and faster: it consists on a proper selection of the configuration of your project in eclipse and using a symbolic link to the deployment directory of the app server: this way, every change in your source code is reflected automatically in the deployment directory (because in fact both are the same directory) and saving a lot of computer time.

Let's go over the details of the process for Linux and Windows.

Steps

Assumptions

For the rest of this article, I will assume that we are working in an JSF eclipse project called “MyTest”. This solution works for every web project: jsp's, jsf, struts, whatever. The solution is very simple as you will see.

I've started with a project with a default configuration:

In eclipse, change the compilation dir of your compiled classes

This directory has to be web/WEB-INF/classes, so that the directory WebContent can be equal as a complete deployed application.

So, right-click on MyTest → properties → Java Build Path and configure the directory so that the binaries are left in the WEB-INF directory:

General instructions

In general, you have to create a symbolic link in the web application of your preference. In this way, whenever a change is made in eclipse, that change is reflected instanly in the webserver. Usually webservers can be configured to redeploy applications everytime a change is detected.

This method has many advantages:

  • you avoid to start and stop the webserver every time you want to redeploy
  • and avoid to pack the web application to be deployed (and afterwards be unpacked by the application server)

An important step is to create a symbolic link, in other words, a directory that points to the same content as other directory. Here are the instructions in different platforms:

Let's say that we have the directory WebContent and we want to create the symbolic link MyTest who points to the same content as WebContent. We can achieve this by issuing the command:

/usr/local/srv/tomcat/webapps$ ln -s /home/user/workspace/MyTest/WebContent/ MyTest

For this example, my application resides in the directory /home/user/workspace/MyTest as you might see.

In this case our application is in the directory c:\workspace\MyTest and our webserver is in the directory c:\tomcat\webapps:

C:\tomcat\webapps>mklink /d MyTest "c:\workspace\MyTest\WebContent"
vínculo simbólico creado para MyTest <<===>> c:\workspace\MyTest\WebContent

Although Windows XP does not have the tools to do it, it can support symbolic links. The only thing you have to do is to download a tool called junction to do the job. After it, it's done:

C:\>junction "c:\tomcat\webapps\MyTest" "c:\workspace\MyTest\WebContent"

This example creates a symbolic link called MyTest who points to the same content as the directory c:\workspace\MyTest\WebContent.

Some examples

Jboss 5 and Windows XP

Tomcat 6 and Linux

java/hotdeploymenteclipse.1398379796.txt.gz · Last modified: 2022/12/02 22:02 (external edit)