This is an introduction tutorial to the newest JBoss AS 7
which appeared in the download section for the first time in Nov 2010.
JBoss AS 7 does not come with an installer; it is simply a matter of extracting the compressed archive.
After
you have installed JBoss, it is wise to perform a simple startup test
to validate that there are no major problems with your Java VM/operating
system combination. To test your installation, move to the bin
directory of your JBOSS_HOME directory and issue the following command:
standalone.bat # Windows users
$ standalone.sh # Linux/Unix users
The above command starts up a JBoss standalone instance that's
equivalent of starting the application server with the run.bat/run.sh
script used by earlier AS releases.
You will notice how amazingly fast
is starting the new release of the application server; this is due to
the new modular architecture, which only starts up necessary parts of
the application server container needed by loaded applications.
If
you need to customize the startup properties of your application
server, then you need to open the standalone.conf (or
standalone.conf.bat for the Windows users) where the memory requirements
of JBoss are declared.
Here's the Linux core section of it:
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.
warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 - Dsun.rmi.dgc.
server.gcInterval=3600000"
fi
So, by default, the application
server starts with a minimum memory requirement of 64MB of heap space
and a maximum of 512MB.
This will be just enough to get started,
however, if you need to run a core Java EE application on it, you will
likely require at least 1GB of heap space or 2GB or more depending on
your application type. Generally speaking, 32-bit machines cannot
execute a process whose space exceeds 2GB, however on 64 bit machines,
there's essentially no limit to process size.
You can verify that the server is reachable from the network by
simply pointing your browser to the application server's welcome page,
which is reachable by default at the well-known address: http://localhost:8080
Connecting to the server with the command line interface
If you have been using previous releases of the application server
you might have heard about the twiddle command -line utility that
queried the MBeans installed on the application server.
This utility has
been replaced by a more sophisticated interface named the Command Line
Interface (CLI), which can be found in the JBOSS_HOME/bin folder.
Just launch the jboss-cli.bat script (or jboss-admin.sh for Linux users) and you will be able to manage the application server via a shell interface.
Now issue the connect [Ipaddress:port] command to connect to the management interface:
[disconnected /] connect
Connected to localhost:9999
Connecting to a remote host
Starting from the
7.1.0 release there is security enabled by default on the AS 7.1
distribution for remote clients.
Thus management interfaces are secured
by default to prevent unauthorized remote access whilst still allowing access for local users for an easier out of the box experience.
If you are connecting to a remote host controller, then you need to provide your credentials:
./jboss-cli.sh --connect 192.168.1.1
Authenticating against security realm: 192.168.1.1
Username:admin
Password:*****
Connected to standalone controller at 192.168.1.1:9999
[
standalone@192.168.1.1:9999 /]
To add new users to your management interfaces, then you need use the add-user.sh/add-user.bat file.
The users defined in the management realm are used for the
authentication of remote CLI clients.
By definition all HTTP access is
considered remote, thus if you want to use the Web administration
console you will need to define users at first.
This utility requires the following pieces of information for the new user: -
- Type - You can choose between application users
(contained in application-users.properties) and management users
(mgmt-users.properties) which is default.
- Realm - this is the name of the realm used to
secure the management interfaces, by default it is 'ManagementRealm' so
you can just press enter, if you change the realm as described below
this is where you need to enter your new realm name.
- Username - the username needs to be alpha numeric.
- Password - At the moment the main restriction on this field is that is can not be the same as the username.
Here's how to add a new Management user.
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): a
Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : user1234
Password :
Re-enter Password :
About to add user 'user1234' for realm 'ManagementRealm'
Is this correct yes/no? yes
Stopping JBoss
Probably the easiest way to stop JBoss is by sending an interrupt signal with Ctrl+C.
However,
if your JBoss process was launched in the background or rather is
running on another machine (see next), then you can use the CLI
interface to issue an immediate shutdown command:
[disconnected /] connect
Connected to localhost:9999
[localhost:9999 /] :shutdown
There is
actually one more option to shutdown the application server, which is
pretty useful if you need to shut down the server from within a script.
This option consists of passing the --connect option to the admin shell,
thereby switching off the interactive mode:
jboss-cli.bat --connect command=:shutdown # Windows
jboss-cli.sh --connect command=:shutdown # Unix / Linux
Restarting JBoss
The command-line Interface contains a lot of useful commands. One of
the most interesting options is the ability to reload all or parts of
the AS confi guration using the reload command . When issued on the root node path of the AS server, it is able to reload the services configuration:
[disconnected /] connect
Connected to localhost:9999
[localhost:9999 /] :reload
The new server structure
The first thing you'll notice when you browse through the application
server folders is that its file system is basically divided into two
core parts: the dichotomy reflects the distinction between standalone servers and domain servers.
A JBoss domain is used to manage and coordinate a set of application server instances.
JBoss AS 7 in domain mode spawns multiple JVMs which build up the domain.
Besides the AS instances, two more processes are created: the Domain Controller which acts as management control point of the domain and the Host Controller which interacts with the domain Controller to control the lifecycle of the AS instances.
JBoss AS 7 running in domain mode
In order to launch JBoss AS 7 in domain mode run the domain.sh/domain.cmd script from the bin folder.
Deploying applications on JBoss AS 7
Applications are deployed differentely depending on the type of
server.
If you are deploying to a domain of servers then you need the
Command Line Interface because the application server needs to be
informed on which server group/s the deployment is targeted.
Ex. Deploy an application on all server groups:
deploy MyApp.war --all-server-groups
Ex. Deploy an application on one or more server groups (separated by a comma):
deploy application.ear --server-groups=main-server-group
If you are deploying to a standalone server then you can either use the CLI or drop the deployment unit into the server deployments folder.
The deployments folder
is the location in which users can place their deployment content (for
example, WAR, EAR, JAR, SAR fi les) to have it automatically deployed
into the server runtime. Users, particularly those running production
systems, are encouraged to use the JBoss AS management APIs to upload
and deploy deployment content instead of relying on the deployment
scanner subsystem that periodically
scans this directory
As soon as the deployer HD scanner detects the application, the
module is moved to the work folder of the application, leaving a
placeholder Test.war.deployed file in the deployments folder.
Note: With the default configuration, packaged archives (.ear, .war, .jar, .sar) are automatically deployed. Exploded archives need adding a .dodeploy empty file in the deployments folder to trigger deployment.<