It's kind of not trivial to use JBoss AS after usage of containers like Apache Tomcat or Jetty. And unfortunately JBoss AS isn't distributed in the way that let it be easily set up as service. This article is just a remember for me how should I install and configure JBoss AS 7.
I'm using Debian Wheezy, but I don't think that for other Linux distributions configuration will differ significantly.
Preconditions
- JDK is installed.
- JAVA_HOME environment variable is set.
For your convenience all following steps were gathered to the script file.
Installation
-
Download JBoss AS 7.
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz
-
Untar the archive.
tar -xvzf jboss-as-7.1.1.Final.tar.gz -C /opt
-
Make a link for easier upgrade of JBoss AS.
ln -s /opt/jboss-as-7.1.1 /opt/jboss-as
-
Create user.
useradd -s /sbin/nologin jboss-as
-
Change owner for jboss-as's directory.
chown -R jboss-as:jboss-as /opt/jboss-as
chown -R jboss-as:jboss-as /opt/jboss-as/
-
Delete downloaded archive
rm jboss-as-7.1.1.Final.tar.gz
-
Initialize JBoss AS as service.
vim /etc/init.d/jboss-as
#!/bin/sh ### BEGIN INIT INFO # Provides: jboss-as # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop JBoss AS 7 ### END INIT INFO JBOSS_USER=jboss-as JBOSS_DIR=/opt/jboss-as case "$1" in start) echo "Starting JBoss AS 7..." start-stop-daemon --start --quiet --background --chuid $JBOSS_USER --exec $JBOSS_DIR/bin/standalone.sh ;; stop) echo "Stopping JBoss AS 7..." start-stop-daemon --start --quiet --background --chuid $JBOSS_USER --exec $JBOSS_DIR/bin/jboss-cli.sh -- --connect command=:shutdown ;; log) echo "Showing server.log..." tail -500f $JBOSS_DIR/standalone/log/server.log ;; *) echo "Usage: /etc/init.d/jboss-as {start|stop}" exit 1 ;; esac exit 0
chmod 755 /etc/init.d/jboss-as
Configuration
-
The default timeout is too low for most of my applications, therefore I override it.
sed -i -e 's, \ <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>, \ <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="240"/>,g' \ /opt/jboss-as/standalone/configuration/standalone.xml
-
I wanna be able to redefine root context, therefore I disable default one.
sed -i -e 's, \ <virtual-server name="default-host" enable-welcome-root="true">, \ <virtual-server name="default-host" enable-welcome-root="false">,g' \ /opt/jboss-as/standalone/configuration/standalone.xml
-
I need port to be listened by all network interfaces therefore I change the way it's set.
sed -i -e 's, \ <inet-address value="${jboss.bind.address:127.0.0.1}"/>, \ <any-address/>,g' \ /opt/jboss-as/standalone/configuration/standalone.xml
Alternatively I could define jboss.bind.address VM parameter. Say in this way
echo 'export JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=192.168.0.1"' >> /opt/profile.d/java.sh
-
Often some application already use port 8080, therefore I prefere change ports that JBoss AS listens to.
sed -i -e 's, \ <socket-binding name="ajp" port="8009"/>, \ <socket-binding name="ajp" port="28009"/>,g' \ jboss-as/standalone/configuration/standalone.xml
sed -i -e 's, \ <socket-binding name="http" port="8080"/>, \ <socket-binding name="http" port="28080"/>,g' \ jboss-as/standalone/configuration/standalone.xml
sed -i -e 's, \ <socket-binding name="https" port="8443"/>, \ <socket-binding name="https" port="28443"/>,g' \ jboss-as/standalone/configuration/standalone.xml
sed -i -e 's, \ <socket-binding name="osgi-http" interface="management" port="8090"/>, \ <socket-binding name="osgi-http" interface="management" port="28090"/>,g' \ jboss-as/standalone/configuration/standalone.xml
Note: It would be better to avoid backslashes and line wrapping in sed expressions. I used them only for markup reasons.
You can find bash script for installation and configuration JBoss AS 7 here.
Comments