Skip to content
Alexander Holbreich
Go back

JBoss 7 setup on debian linux

This is a short step-by-step setup guide for JBoss 7.0.2 on Linux ((Debian). Nowadays there is still no official Debian package for JBoss 7 out there, so we have to do a couple of steps manually. 

1. download and prepare

Start by download the currently available version (7.0.2) of the JBoss 7.

#Web Profile version download.
wget http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-web-7.0.2.Final.tar.gz

Extracting files to the final location using tar.

tar zxvf jboss-as-web-7.0.2.Final.tar.gz -C /usr/local/

Now your JBoss 7 is placed inside /usr/local/jboss-as-web-7.0.2.Final/. I don’t like that name. It’s just cosmetics, but I prefer to rename the last part of the path.

cd /usr/local/
mv jboss-as-web-7.0.2.Final/ jboss-7.0.2

Now basic security, we don’t want to start JBoss with root rights. Therefore we need to create new user and new group named jboss. Make them owners of your JBoss files:

addgroup jboss
useradd -g jboss jboss
chown -R jboss:jboss /usr/local/jboss-7.0.2/

Your JBoss 7 is almost installed now.

2. Configuration and the first test

Start your brand new JBoss 7 server with:

sudo -u jboss sh /usr/local/jboss-7.0.2/bin/standalone.sh &

Now it is testable on your local machine with http://localhost:8080 But if you trying to install JBoss on the remote machine and want to access this installation remotely, you need to enable the remote interface of your JBoss. I assume we start by standalone configuration, so you have to edit /usr/local/jboss-7.0.2/standalone/configuration/standalone.xml file. The easiest way is to search for <interfaces> section and replace the 127.0.0.1 address with <any-address/>

<interfaces>
  <interface name="management">
    <any-address/>
  </interface>
  <interface name="public">
    <any-address/>
  </interface>
</interfaces>

Beware of what you doing here, you expose also the management console to the public. Now you can access your jboss from anywhere. The console is bounded to interface named=“management” by default.In production environments, you have to put more attention to this.

3. JBoss as Service

Now we have a basic configured JBoss, but I want to maintain it as a service. Unfortunately, JBoss archive has no predefined init.d scripts, so I have to to it on my own. But this is not a big problem, just straightforward following some Debian conventions and useful scripts.

Ok, let’s create JBoss maintenance script.

touch /etc/init.d/jboss
chmod 755 /etc/init.d/jboss

Ready! Now put the following inside.

#!/bin/sh
#BEGIN INIT INFO
#Provides: jboss
#Required-Start: $localfs $remotefs $network $syslog
#Required-Stop: $localfs $remotefs $network $syslog
#Default-Start: 2 3 4 5
#Default-Stop: 0 1 6
#Short-Description: Management of JBoss AS v7.x
#END INIT INFO
#Defining JBOSS_HOME
JBOSS_HOME=/usr/local/jboss-7.0.2

case "$1" in 
start) 
echo "Starting JBoss AS7..." 
sudo -u jboss sh ${JBOSSHOME}/bin/standalone.sh & 
;; stop) 
echo "Stopping JBoss AS7..." 
sudo -u jboss sh ${JBOSSHOME}/bin/jboss-admin.sh --connect command=:shutdown 
;; log) 
echo "Showing server.log..." 
tail -1000f ${JBOSS_HOME}/standalone/log/server.log 
;; *) echo "Usage: /etc/init.d/jboss {start|stop|log}" 
exit 1 
;; esac exit 0 

This file is ready to use. You can use itself for the manual start and stop of your JBoss, you also can follow the server.log by using “log” parameter. But let’s make it to the end, as an automatic starting service. It’s easy with update-rc.d script:

update-rc.d jboss defaults

Now your ready and your JBoss will be shut down on machine shutdown and it should start on machine start-up.

Of course, this is not the only way to start using JBoss 7. Your ideas are welcome!


Archived comments (16)

These comments were migrated from Disqus and are no longer accepting replies.

  • MM

    Jboss was not running for be me :( Error parsing configuration...

  • AlexH

    Hi MM, could you be more precise?
    Error on configuration parsing points you to some problems in some of the configuration file.
    Which of them did you changed?

  • RaphaelH

    With the release of version 7.1 the syntax for the configuration-files changed a little.
    Instead of you have to use now. Otherwise you get the mentioned "Error parsing configuration" Exception.
    There is no solution by JBoss yet, in the forums (https://community.jboss.org... this workaround got mentioned and is working fine as far as I can tell.

  • RaphaelH

    instead of "any-adress" you have to use "any-ipv4-address" now. Sorry, the tags didn't escape but got cut out completely.

  • Knut Meyer

    Thanks!

    For my JBoss 7.1.1 installation i have to use jboss-cli.sh instead of jboss-admin.sh in startscript to stop server.

  • hilner

    i got the error:

    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ..
    at org.jboss.logmanager.config.AbstractPropertyConfiguration$1.applyPostCreate(AbstractPropertyConfigurati...:175)
    ...
    at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:393)
    ...
    Caused by: java.io.FileNotFoundException: /usr/local/jb6/domain/log/process-controller.log (Permission denied)
    at java.io.FileOutputStream.open(Native Method)
    ...

  • AlexH

    Hey hilner, i've shortened your stacktrace to the problem case... Hope it's ok?
    Seemed that your Jboss can't read that file /usr/local/jb6/domain/log/process-controller.log

    And by the way, please provide a bit more elaborate question next time. ;)

  • rjsl

    To stop it: sudo -u jboss sh /usr/local/jboss-7.0.2/bin/jboss-admin.sh --connect command=:shutdown

  • AlexH

    @Luigi Padovani  Thank you for your questrion. Lets' take standalone configuration again. Change default port is possible in config file JBOSS_HOME/standalone/configuration/standalone.xml.
    Search for socket-binding-group section.
    You will find something like this: 
     <socket-binding-group name="standard-sockets" default-interface="public">       
    <socket-binding name="http" port="8080"/>
    ... 
    </socket-binding-group>
     
    Change 8080 to desired port, restart, enjoy! ;)

  • mp

    the shutdown command try to connect to localhost:9999 but jboss 7 is running on 1.2.3.4:9999, what configuration file can i change for shutdown connect to 1.2.3.4:9999?

  • Pp

    Thank you for the great tutorial.
    By entering the administration console there is no login dialog. I'm right in the console. How can I activate the authentication?

  • AlexH

    Just testet selfbuilded  With JBoss 7.1.3-Final on Xubuntu 13.04They host it on the Github.
    Alors:
    wget https://github.com/jbossas/...
    sudo tar zxvf 7.1.3.Final.tar.gz 
    build.sh
    Of course you need http://alexander.holbreich....
    and http://alexander.holbreich....

  • Ken Cent

    Thank you! so very helpful! If your jboss configuration does not have the jboss-admin.sh, then just change the line to:

    tail -1000f ${JBOSS_HOME}/jboss-cli.sh --connect command=:shutdown

    to enable the shut down.

  • AlexH

    I must confess i didn't much with Jboss for several month... And don't have any instance where i could test it. But maby i will come across Wildfly soon, to test some stuff... Thank you anyway ;)

  • Dj_dracKo

    [jboss@mxeisapp02 init.d]$ service jboss start
    /etc/init.d/jboss: line 1: !/bin/sh: No such file or directory
    /etc/init.d/jboss: line 2: BEGIN: command not found
    /etc/init.d/jboss: line 3: Provides:: command not found
    /etc/init.d/jboss: line 4: Required-Start:: command not found
    /etc/init.d/jboss: line 5: Required-Stop:: command not found
    /etc/init.d/jboss: line 6: Default-Start:: command not found
    /etc/init.d/jboss: line 7: Default-Stop:: command not found
    /etc/init.d/jboss: line 8: Short-Description:: command not found
    /etc/init.d/jboss: line 9: END: command not found
    /etc/init.d/jboss: line 10: Defining: command not found
    /etc/init.d/jboss: line 25: syntax error near unexpected token `exit'
    /etc/init.d/jboss: line 25: `;; esac exit 0 '

    Not working for me... :(

  • AlexH

    Looks like '#' got mission somehow on the first 10 lines of the file:
    /etc/init.d/jboss

    if've fixed that now. Please update and let me know if things are better now...