From Fedora Project Wiki

Packaging Java Web Applications

Please contribute to discussion
Most of discussion points that were mentioned here were removed, with an effort to integrate parts that discussed deeply enough to make a conclusion in this draft. Look in the history to see what they were and feel free to raise them again if you feel otherwise. Feel free to comment on anything if you disagree, of have an idea how to improve the draft.
Java Guidelines
Please be sure to read Java Packaging Guidelines. They contain information that is generally useful when dealing with Java packages, and need to be complied with.
Web Applications
We really need a separate section for web application policies within Fedora (for all web applications, not just Java related ones)

Web Application Archives

Web applications can be written in Java to be deployed on a Java web server (for example Tomcat and Jetty). These applications are bundled into what is referred to as a WAR file. Like a JAR file, a WAR file is similar to a zip archive and contains all data needed to run the application, this includes things like images, html pages, servlets, JAR files and configuration files.

The problem with WARs is that they contain JAR files which may already exist on the system. This means that JAR files would have to be maintained in multiple locations on the machine. Fortunately, most servers can use WAR files in an exploded format. This means that the WAR file is expanded into a directory structure instead of being an archive and we can symbolically link the JAR files as needed; e.g. package foo which provides foo.war, the package would have:

webapps/%{name}/foo/
webapps/%{name}/foo/WEB-INF/lib/bar1.jar -> %{_javadir}/bar1.jar
webapps/%{name}/foo/WEB-INF/lib/bar2.jar -> %{_javadir}/bar2.jar

Directory structure

Server independent part

According to existing practice, the web application data should be placed to %{_datadir}. The package can contain more than a single web application -- it can contain a GUI or CLI application, either of them possibly using %{_datadir}/%{name}, or multiple web applications. A web application is possibly named differently from the package. Therefore use of %{_datadir}/%{_name} should be avoided.

A suitable name, what would prevent all sorts of naming conflicts would be %{_datadir}/webapps/%{name}/foo. Note that the name webapps was chosen after existing naming practice of Tomcat. foo stands for name of the web application archive stripped of .war suffix, since it's no longer an archive.

Existing practice
Non-java based web applications such as squirrelmail, phpMyAdmin or bugzilla currently use %{_datadir}/%{_name}. Should we follow that practice, not taking the above paragraphs into account?

The configuration files should not go to %{_datadir}, but rather in %{_sysconfdir}, and be symbolically linked to where the web application expects it (%{_datadir}).

Server dependent deployment

Deployment is done by symbolically linking the directory with unpacked web application into server's webapps directory.

Example

To be written

Random notes

Fedora 9's build-jar-repository will probably not be able to create symlinks. Would it be okay if we either choose the abs2rel way or tolerated absolute links until Fedora 10, and add the feature until then.

There are other java web archives such as EARs, SARs, HARs, CARs, ... which deal with Java Enterprise Edition (JEE) Application Servers. These will need to be treated in the same manner as WARs. A section will be available here once a JEE server is available in Fedora.