Simple Java Web Application Installation (Part 1)
So, you wrote your super web application in Java and now you want as many people as possible to download, install, and start using it? Everything is fine, only for some java-programmers, especially for those who have lived in the J2EE world for the last five years, it may be a discovery that for 99.9% of people in this world the words “Just shut this WAR-nickname onto your favorite server” will be an empty sound. Well, ok, maybe not 99.9% but 99.8% - or so.
Below is the first part of the tutorial on how to make a beautiful Windows Installer out of your varnik (yes, not only do most people don’t know the word deployment, they also use Windows!) Using WiX
So we have:
We want to create the installation of our application through the Windows Installer . During installation, you must:
What we will use:
All products are Open-Source.
Some points may not be fully disclosed here - any questions and suggestions are welcome. This solution was used to create an installer for the EmForge project - this project is open-source, so a working example can be obtained from its source (for example, via the web-viewer: www.emforge.org/browser/EmForge/trunk or simply by taking the source from svn repository svn.emforge.org/svn/emforge/EmForge/trunk
In this part we will look at the process of creating a zip archive with an application ready to launch.
So, let's go ...
First of all, we need to save the user from understanding the word Deploy. There are several possible solutions, for example, you can pack a simple server directly into a war nickname, as they do in Hudson (an interesting solution - but I have not figured it out yet). We will go the other way - and create a Zip archive in which we put Jetty, configured to run our war nickname.
The idea was taken from this blog: blog.devspan.com/2008/02/creating-distributable-war-project-with.html - here I will describe only the main idea (if necessary - tell me - I will write in more detail):
As a result, we get the zip in which jetty and your application will lie. The structure of the zip will be approximately as follows: Please check:
Well that's all for now. In principle, this can and will stop - not a lazy user can just download the zip, unzip it and start the server with your application using run.bat or run.sh
We will talk about the solution for “lazy” users in the next series
Below is the first part of the tutorial on how to make a beautiful Windows Installer out of your varnik (yes, not only do most people don’t know the word deployment, they also use Windows!) Using WiX
Formulation of the problem
So we have:
- The web application itself is written in Java. In this case, it is assumed that the application is being built using maven (if you are not already doing this, I highly recommend it). As a result of the assembly, you get a war file (ok - not a full EAR - but for EAR you just need to pack another server)
- It is assumed that this application runs under the Jetty 6.0.x server (if not, then again - you just need to pack another server)
We want to create the installation of our application through the Windows Installer . During installation, you must:
- Perform standard actions (ask where to install, show license, show progress)
- Install the application itself to the specified location
- Configure its launch as a service
- Add a link to the main page of the application on the Desktop (so that the user can easily access it)
What we will use:
All products are Open-Source.
Some points may not be fully disclosed here - any questions and suggestions are welcome. This solution was used to create an installer for the EmForge project - this project is open-source, so a working example can be obtained from its source (for example, via the web-viewer: www.emforge.org/browser/EmForge/trunk or simply by taking the source from svn repository svn.emforge.org/svn/emforge/EmForge/trunk
In this part we will look at the process of creating a zip archive with an application ready to launch.
So, let's go ...
Packing the application with Jetty
First of all, we need to save the user from understanding the word Deploy. There are several possible solutions, for example, you can pack a simple server directly into a war nickname, as they do in Hudson (an interesting solution - but I have not figured it out yet). We will go the other way - and create a Zip archive in which we put Jetty, configured to run our war nickname.
The idea was taken from this blog: blog.devspan.com/2008/02/creating-distributable-war-project-with.html - here I will describe only the main idea (if necessary - tell me - I will write in more detail):
- We have a web project assembled by the maven (http://www.emforge.org/browser/EmForge/trunk/emforge-web in our case)
- Create a new launcher project. The structure of the project and the required files can simply be copied from emforge-launcher by dipping it with a file for your project: www.emforge.org/browser/EmForge/trunk/emforge-launcher
- We configure maven-assembla-plugin in this project so that it takes the varnik and the required jetty libraries from the maven repository and puts them in the “right” places
- First, run mvn clean install in our web project, so that maven collects and puts our project in the local repository
- Then run mvn clean assembly: assembly in the launcher project - as a result, we get the required zip
As a result, we get the zip in which jetty and your application will lie. The structure of the zip will be approximately as follows: Please check:
- etc Каталог с настройками Jetty
- jetty.xml
- jetty-win32-service.xml
- webdefault.xml
- lib Каталог с с файлами, требуемыми для старта jetty
- wrapper.dll
- wrapper-3.2.0.jar
- jety-6.1.14.jar
- jetty-util-6.1.14.jar
- jetty-win32-service-java-6.1.14.jar
- servlet-api-2.5-6.1.14.jar
- start-6.1.14.jar
-logs Место куда должны ложиться логи
- webapps
- root А тут должно оказаться ваше приложение
Jetty-Service.exe Этот файл поможет запустить jetty как сервис
jetty-service.conf А это го настройка
- jetty-service.conf should contain the name of your service. By default it will be Jetty - but for sure you want something else
- also check that jetty-service.conf contains the correct paths to libs & logs
- In jetty.xml check the port on which the service will be launched - by default it is 8080, but this port is very widely used and therefore it is better to use some other port
- The root directory must contain your web application, that is, the WEB-INF directory must lie directly under root
Well that's all for now. In principle, this can and will stop - not a lazy user can just download the zip, unzip it and start the server with your application using run.bat or run.sh
We will talk about the solution for “lazy” users in the next series