Raspberry Pi is a popular single-board computer based on an ARM processor. This system is capable of running Linux. Java is also available for Linux on ARM as OpenJDK and Oracle Java SE. With JBoss AS 7 exists a lightweight Java EE 6 compliant application server. Sounds like an interesting environment to run little embedded Java EE applications. So will JBoss AS run on a small Raspberry Pi?
Prepare Your Raspberry Pi
Before we begin we need to choose a Linux distribution for your Raspberry Pi. The ready to run images of Debian GNU/Linux at http://www.raspberrypi.org/downloads are a perfect and easy to use basis. Because we will use an Oracle JVM we download and install the soft-float Debian “wheezy”.
After booting Debian it’s a good idea to enable the SSH server via raspi-config
to administer our Raspberry via network (see figure 1). Our setup will be a headless server. The resources for a graphical GUI are better used for our Java process running JBoss AS.
Figure 1: Enabling SSH server via raspi-config.
Therefore we will reduce the memory for the graphics card. The Raspberry Pi is a small platform. It provides only 256 MiB of RAM. To use the half of the memory for a graphical GUI seems to be a sin. We want to run a server, not a workstation!
So we select memory_split
in the main menu of raspi-config
and set the splitting to the lowest value: 224MiB for ARM, 32MiB for VideoCore (see figure 2). After setup of SSH server and reducing of video memory a reboot is necessary.
Figure 2: Reducing memory for VideoCore to the minimum.
Setup of Java SE
There are two options of a JVM for Raspberry. We can install OpenJDK or a Oracle Java SE. We will use Oracle’s one. Unfortunately the standard Java SE of Oracle for Linux on ARM will not be able to provide a server JVM on the Raspberry Pi. The little single-board computer uses an ARMv6 compatible processor. Oracle Java SE for Linux/ARM is only capable of providing a server JVM on ARMv7. A client JVM runs also on ARMv6 but is not sufficient for a server process such as JBoss AS.
Good to hear that there is another JVM for Linux/ARM available at Oracle: Java SE Embedded. We download the “ARMv6/7 Linux – Headless EABI, VFP, SoftFP ABI, Little Endian“ which is able to provide a suitable JVM for JBoss AS on Raspberry Pi. The installation of the current eJRE (v7 update 10 as time of writing this post) is very easy:
$ sudo mkdir /usr/java $ sudo tar xzfC ejre-7u10-fcs-b18-linux-arm-vfp-client_headless-28_nov_2012.tar.gz /usr/java
After these operations there is new directory /usr/java/ejre1.7.0_10
containing Java SE. A short test will prove that it is runs on the Raspberry Pi:
$ /usr/java/ejre1.7.0_10/bin/java -version java version "1.7.0_10" Java(TM) SE Embedded Runtime Environment (build 1.7.0_10-b18, headless) Java HotSpot(TM) Embedded Client VM (build 23.6-b04, mixed mode)
Setup of JBoss AS 7
Now it’s time to setup JBoss AS 7. The following steps work for JBoss AS 7.1.1.Final but should also work for upcoming versions of JBoss AS 7. First of all let’s extract the zip file:
$ sudo mkdir /usr/jboss $ sudo unzip -d /usr/jboss jboss-as-7.1.1.Final.zip
After that we setup a system user for JBoss:
$ sudo useradd -c "JBoss AS User" -s /bin/bash -d /home/jboss -mr jboss $ sudo chown -R jboss:jboss /usr/jboss/jboss-as-7.1.1.Final
Let’s switch to this new user:
$ sudo su - jboss
Now we need to configure JBoss AS and therefore we open the standalone.conf
with vi
:
$ vi /usr/jboss/jboss-as-7.1.1.Final/bin/standalone.conf
At the beginning of this file we set the JAVA_HOME
environment variable:
JAVA_HOME=/usr/java/ejre1.7.0_10
At the end of the standalone.conf
we have to change the memory settings for the JVM process. The default settings of a maximum heap of 512 MiB are a bit to much for the Raspberry Pi. Appropriate settings for a Raspberry Pi are: -Xms64m -Xmx196m -XX:MaxPermSize=64m
. So we change the corresponding command line switches in variable JAVA_OPTS
in standalone.conf
.
Note: Do not reduce the MaxPermSize
lower than 64m
otherwise you will encounter serious problems while loading classes. For example with a setting of 32m
I even wasn’t no longer able to shutdown a running JBoss AS via a remote JBoss CLI! The necessary shutdown classes could not be loaded any more. 😉
Last but not least we need to configure the management and public network interface to accept connection from external. So we edit standalone-full.xml
:
$ vi /usr/jboss/jboss-as-7.1.1.Final/standalone/configuration/standalone-full.xml
We find the interfaces section and configure 0.0.0.0 to bind the server to all IP addresses:
<interfaces> <interface name="management"> <inet-address value="0.0.0.0"/> </interface> <interface name="public"> <inet-address value="0.0.0.0"/> </interface> <interface name="unsecure"> <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/> </interface> </interfaces>
JBoss AS 7 is now configured and is ready to run. To provide an admin user for the web-console and the CLI we create a new one by starting add-user.sh
:
$ cd /usr/jboss/jboss-as-7.1.1.Final/bin $ JAVA_HOME=/usr/java/ejre1.7.0_10 ./add-user.sh
Starting JBoss AS
Now we are ready to start JBoss AS with it full standalone profile:
$ cd /usr/jboss/jboss-as-7.1.1.Final/bin $ ./standalone.sh -c standalone-full.xml
We start a web browser on your workstation and open http://raspi-addr:9990/console/App.html
. raspi-addr
must be replaced by the IP address of the Raspberry Pi (can be determined by invoking ifconfig eth0
on Raspberry’s shell).
Figure 3: Web-console of JBoss AS on Raspberry Pi.
The JBoss AS on Raspberry Pi is now ready for deployments.
I deployed already a few samples of jboss-jdf-jboss-as-quickstart-32304a4
. The samples which I tried ran without problems. On the Raspberry Pi JBoss AS can be run and it is able to provide at least little applications without any problems.
Hi! have you tried jboss7 + postgres on the pi? I need a small server with a couple ws, and I was thinking on jboss and postgres, do you know if the pi can handle that?
Hi Mauricio,
I did not try JBoss AS 7 and PostgreSQL on one Raspberry Pi yet. I think it could be possible that a Pi would handle that configuration and the additional load.
First of all I would use the new Pi model B with 512 MB of RAM (released in October 2012). That might handle the additional demand of memory. Whether the CPU might be sufficient for your application I am not able to tell without further information.
Another approach for a Java EE application on a little embedded system might be to use an embedded database management system, such as Apache Derby, instead of PostgreSQL.
Regards,
Oliver
Hi Muller!
Great and very useful article, thanks!
I just wanted to share another configuration that maybe can help some users, if you agree.
As is commented in several sites there are problems when installing the ‘soft-float’ OS version in some Rapsberri Pi.
So, this was my configuration options to get working the JBoss AS 7 in a Raspberry Pi:
– Install the ‘hard-float’ OS version.
– Install the JDK 8 EA version of the jvm. Yes, it’s still an early access version and it’s not bug free, but worked for me. https://jdk8.java.net/download.html
– Follow your article step by step! ; )
– Before starting the JBoss AS 7, modify the JVM options params to set the java options to ‘-client’ (the ‘-server’ option is set by default and it’s not working with this JVM).
Modify the ‘standalone.conf’ and add the ‘-client’ in the same lines that were modified to tune up the JVM memory.
– Run the JBoss AS 7 (./standalone.sh -c standalone-full.xml) and check that the following line is displayed:
JAVA_OPTS: -client -Xmsblablabla….
– I’ve checked that a simple HelloWorld application works ok but be warned that some applications may not run due to the JDK 8.
Regards,
Randy.
Pingback: JBoss AS7 | raspinotes