Deploying static content on JBoss server

Recently, I had a question from a commenter on my blog post on installing ELK stack on Ubuntu/Debian. The question was how to serve kibana 3 via a server like jboss. Kibana 3 is essentially (more or less) static content. It serves html and content changes based on it's querying elasticsearch via javascript. I couldn't find any blog with all the instructions in one page for serving static content via Jboss. So here it is:

These instructions are for JBoss Application Server 7:

Install JBoss

If you already have JBoss installed then you can skip this step.

Download and extract JBoss:

cd /tmp  
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz  
tar -xvf jboss-as-7.1.1.Final.tar.gz  

Move extracted JBoss to /usr/local/share

mv /tmp/jboss-as-7.1.1.Final /usr/local/share/jboss-7.1.1  


Deploying static content to JBoss:
  • Create a directory called yourwebapp.war inside /usr/local/share/jboss/standalone/deployments
  • Create a file name yourwebapp.war.dodeploy in /usr/local/share/jboss/standalone/deployments
  • Create a directory WEB-INF inside yourwebapp.war
  • Create a file web.xml with contents shown below
<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
</web-app>  
  • Start JBoss
  • Browse to your server's ipaddress:8080/yourwebapp
An example of deploying static content to JBoss:

I am demonstrating static content deployment to JBoss with kibana 3 content.

cd /usr/local/share/jboss-7.1.1/standalone/deployments/  
sudo mkdir -p kibana.war/WEB-INF  
sudo cp -r /tmp/kibana-3.1.2/* kibana.war  
sudo touch kibana.war.dodeploy  

Create web.xml with contents shown below: vi kibana.war/WEB-INF/web.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
</web-app>  

Start JBoss:

cd /usr/local/share/jboss  
./bin/standalone.sh -Djboss.bind.address=192.168.1.8 -Djboss.bind.address.management=192.168.1.8

Browse to: http://192.168.1.8:8080/kibana

Please replace 192.168.1.8 with your server's ip address