Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.war files packaged as RPMs for JBOSS/Tomcat - best practices?

Tags:

war

jboss

rpm

I'm planing to package WAR files as RPMs. Current deployment process just doesn't work for us and my idea of fixing it would be to create a new Custom Channel in RHN Satellite and publish my WAR files through that Channel. Currently (as we are trying to win some time) I'm managing some config files through Satellite so configs are not a big problem. We don't keep them in WAR for many reasons but that's different story.

Anyway, has anyone packaged WAR as RPMs? Do you do hot deployment or do you force JBOSS/Tomcat to restart? Is that After RPM installation or as a part of it? What's your SPEC file looks like? Can I please see it as an example? Do you check in your SPEC for JBOSS/Java/Oracle client or just install WAR? Any stories to tell? Any major problems? Should I consider something else? I can build RPMs no problem but I'd like to hear what's the best way of doing this with WAR files and JBOSS (some Tomcats are still running here but they will be phased out soon-ish so I'm not too worried about them).

I do appropriate any input.

Thanks in advance Kind Regards Chris

like image 435
Chris Avatar asked Jan 27 '12 10:01

Chris


2 Answers

I have packaged a WAR file and its companion config file as RPM. My SPEC file checks whether JBoss is running. If it is, the installation exits with an error message, requesting that JBoss be stopped before installation.

In general, it is not a good idea to kill processes or force restart through RPMs. The person in charge of installation should have a separate procedure for doing this.

Other considerations:

1. Does your organization have other installations on the same server?

If so, you might want to standardize on a path under which all installations on the server will go. (For example, /usr/local/bin/myorg/) It might also help to have a custom *nix user and group, for which file attributes are set for all installations on the server.

2. Do you want a relocatable RPM?

Is there ever a chance that you might want to change the default path for your installation? If so, a relocatable RPM will help. There are conditions where a relocatable RPM may not work, so check out these things to consider at www.rpm.org.

3. Do you want to back up an existing deployment when your RPM runs?

If so, you would need to write that code in your SPEC file.

Here is my complete SPEC file:

Summary: Summary for my Java project
Name: Name for my Java project
Version: 2.1.2
Release: 5
Requires: jboss >= 5.1
BuildArch: noarch
Group: Internet / Applications
Prefix: /usr/local/bin
License: (C) Copyright my organization
Vendor: my organization

%description 
Description for my Java project

%prep
# Check if the WAR file has been created

%install
# Copy war file to buildroot's Jboss deployment directory
# Copy config file to buildroot's Jboss config directory

%files
# Set file permissions and ownership

%pre
# Check if JBoss deployment path exists on the web server. 
# If not, exit with an error. 

# Check if JBoss config file path exists on the web server. 
# If not, exit with an error. 

# Check if custom user 'myuser' exists. If not, exit with an error.
# Check if custom group 'mygroup' exists. If not, exit with an error
# Check if JBOSS is running. If yes, exit with an error.   
# Take backup of existing deployment, if needed.

%post
# Perform post-installation steps, if needed.
echo "Installation complete."
like image 52
nohup Avatar answered Oct 24 '22 10:10

nohup


We plan to somehow standardize Java webapp installation on Fedora, but there is nothing yet. Debian guys created a rather nice proposal http://dep.debian.net/deps/dep7 which you should probably read to get an idea what you'd have to deal with more or less.

As for JBoss/Tomcat restart, I would advise against it. Leave it to the system (webserver) administrator. They should know what they are updating and why. Forcing restart of webserver all the time is asking for trouble IMO (especially if one server is hosting multiple webapps)

I would put the wars in /usr/share/webapps-java. Then probably have JBoss/Tomcat use that directory. That said, no spec files, sorry.

like image 1
Stan Avatar answered Oct 24 '22 11:10

Stan