Posted by & filed under Linux, Personal, Software.

  • DZone
  • Reddit
  • HackerNews
  • Twitter
  • Facebook
  • Google Plus
  • Pinterest
  • StumbleUpon
  • LinkedIn
  • Tumblr
  • BlinkList
  • Mister Wong
  • Add to favorites
  • Email

This is a short step by step explanation of the setup of JBoss 7.0.2 on your Linux (explicit debian). Nowadays there is still no official Debian package for JBoss 7 out there, so we have to do a couple of steps manually.  First i describe how to download and to prepare the jboss. Secondly we do some basic configuration that you’ll be needed and at the end i will show you one of the ways to register JBoss as a service.

1. download and prepare.

Start by download  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.

<pre>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 dont’t like that name.  It’s just cosmetics, but i prefer to rename the last part ot the path.

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

Now important things. Some basic security and right management. I suppose  you don’t want to start your JBoss with root rights.
Therefore we need to create new user and new group named  jboss. Make them owner of your JBoss stuff.

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 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! maybe you trying to install that jboss on remote machine and want to access this installation remotely. I that case you need to enable 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  find <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 with this configuration you expose also the management console to the public. The console is bounded to interface named=”management” by default.  In production environments you have to put more attention to this. but now you can access your jboss from anywhere.

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 following inside.

#!/bin/sh
### BEGIN INIT INFO
# Provides: jboss
# 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: 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 ${JBOSS_HOME}/bin/standalone.sh &
;;
stop)
echo "Stopping JBoss AS7..."
sudo -u jboss sh ${JBOSS_HOME}/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 it self for 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 shutdown 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!

14 comments
Pp
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?

mp
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?

Luigi Padovani
Luigi Padovani like.author.displayName 1 Like

the port 8080 is used from apache how to change defaut port of jboss?

 

 

shuron
shuron moderator

 @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! ;)

rjsl
rjsl

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

shuron
shuron

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. ;)

hilner
hilner

i got the error: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) .. at org.jboss.logmanager.config.AbstractPropertyConfiguration$1.applyPostCreate(AbstractPropertyConfiguration.java: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) ...

Knut Meyer
Knut Meyer like.author.displayName 1 Like

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.

RaphaelH
RaphaelH

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

RaphaelH
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/thread/198106?tstart=0) this workaround got mentioned and is working fine as far as I can tell.

shuron
shuron

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?

MM
MM

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