Tag: JBoss AS7

Free JBoss AS7 (EAP 6) Course

In the vain of its creator (Red Hat): “… we gain the most when we share. It is core to our business and our development models.” As a result, we are bringing you a free course on JBoss AS 7 (EAP 6). In the course you will learn the following:

  • Introduction
    • JBoss Application Server architecture (standalone, process controller, host controller, domain)
    • JBoss Application Server internal architecture (listen threads, threads pools, containers)
    • Standalone configuration
    • Command-line utility
    • Admin console
  • JVM Tuning
    • Code generation
    • Memory management
    • Garbage collection performance
    • JConsole and JVisualVM
  • Deployment
    • Packaging applications recommendations
    • Deployment descriptors
    • Server logging
    • Front-end configuration using the Apache HTTP Server and mod_jk
  • Class Loading
    • Modules
  • Security
    • JAAS introduction
    • Role-based security
    • Secure communications (SSL and TLS)
  • Configure Resources
    • Domain configuration
    • Configure data sources
    • Monitoring resources
    • Configure JMS environment
  • Clustering
    • Unicast or multicast?
    • Denial of service configuration
    • Vertical and horizontal scaling
    • Caching
    • Apache HTTP Server and mod_cluster
    • Load balancing
    • Load testing

Note that this is a course you can do at your own pace. The exercises lead you step-by-step through the process of installing, configuring, deploying etcetera. The material consists of the following:

Have fun!


Bridging JMS HornetQ to JBossAS7

In this post we are going to set-up a (JMS) bridge in order to forward messages from a stand-alone HornetQ Server to JBoss AS7. We end the post by looking at the performance, such as Operating System and JVM tuning, and make a suggestion in chosing a Java Virtual Machine when dealing with very large heaps (> 100GB).

Set-up HornetQ

HornetQ distributions can be obtained here. In the examples we will work with the 2.2.14.Final distribution. To install HornetQ just unzip the downloaded distribution. Let us start with a basic HornetQ set-up and create a connection factory and a queue. Open the hornetq-jms.xml (located in the ${HORNETQ_HOME}/config/stand-alone/non-clustered directory) and add the following

<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
	<connection-factory name="SomeConnectionFactory">
		<xa>false</xa>
		<connectors>
			<connector-ref connector-name="netty"/>
		</connectors>
		<entries>
			<entry name="jms/SomeConnectionFactory"/>
		</entries>
	</connection-factory>

	<queue name="SomeQueue">
		<entry name="jms/queue/SomeQueue"/>
	</queue>
</configuration>

The connectors are defined in the hornetq-configuration.xml file, i.e.,

<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">

	<security-enabled>false</security-enabled>
	<cluster-user>employee</cluster-user>
	<cluster-password>welcome1</cluster-password>

	<connectors>
		<connector name="netty">
			<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
			<param key="host"  value="${hornetq.remoting.netty.host:middleware-magic.com}"/>
			<param key="port"  value="${hornetq.remoting.netty.port:4445}"/>
		</connector>
		<connector name="netty-throughput">
			<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
			<param key="host"  value="${hornetq.remoting.netty.host:middleware-magic.com}"/>
			<param key="port"  value="${hornetq.remoting.netty.batch.port:4455}"/>
			<param key="batch-delay" value="50"/>
		</connector>
	</connectors>

	<acceptors>
		<acceptor name="netty">
			<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
			<param key="host"  value="${hornetq.remoting.netty.host:middleware-magic.com}"/>
			<param key="port"  value="${hornetq.remoting.netty.port:4445}"/>
		</acceptor>
		<acceptor name="netty-throughput">
			<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
			<param key="host"  value="${hornetq.remoting.netty.host:middleware-magic.com}"/>
			<param key="port"  value="${hornetq.remoting.netty.batch.port:4455}"/>
			<param key="batch-delay" value="50"/>
			<param key="direct-deliver" value="false"/>
		</acceptor>
	</acceptors>

	<security-settings>
		<security-setting match="#">
			<permission type="createNonDurableQueue" roles="guest"/>
			<permission type="deleteNonDurableQueue" roles="guest"/>
			<permission type="consume" roles="guest"/>
			<permission type="send" roles="guest"/>
		</security-setting>
	</security-settings>

	<address-settings>
		<address-setting match="#">
			<dead-letter-address>jms.queue.DLQ</dead-letter-address>
			<expiry-address>jms.queue.ExpiryQueue</expiry-address>
			<redelivery-delay>0</redelivery-delay>
			<max-size-bytes>10485760</max-size-bytes>
			<message-counter-history-day-limit>10</message-counter-history-day-limit>
			<address-full-policy>BLOCK</address-full-policy>
		</address-setting>
	</address-settings>

</configuration>

Apart from the addition of the security-enabled, cluster-user and cluster-password elements and the host and port settings, all is present by default. Next, we are going to define a different user. In order to do this open the hornetq-user.xml and add the following

<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
	<!-- the default user.  this is used where username is null-->
	<defaultuser name="employee" password="welcome1">
		<role name="guest"/>
	</defaultuser>
</configuration>

Start the HornetQ Server by running run.sh (located in the ${HORNETQ_HOME}/bin directory. Before we can execute run.sh, we have to make sure it points to the right JAVA_HOME, for example, open run.sh and add the following lines

#!/bin/sh

export JAVA_HOME=/home/jboss/jdk1.6.0_31
export PATH=${JAVA_HOME}/bin:${PATH}

With everything in place we can start the HornetQ Server

[jboss@middleware-magic bin]$ ./run.sh
***********************************************************************************
java  -XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M -Dhornetq.config.dir=../config/stand-alone/non-clustered -Djava.util.logging.config.file=../config/stand-alone/non-clustered/logging.properties -Djava.library.path=. -classpath ../lib/twitter4j-core.jar:../lib/netty.jar:../lib/log4j.jar:../lib/jnpserver.jar:../lib/jnp-client.jar:../lib/jbossts-common.jar:../lib/jboss-mc.jar:../lib/jbossjta.jar:../lib/jboss-jms-api.jar:../lib/jboss-javaee.jar:../lib/jboss-client-7.1.0.Final.jar:../lib/hornetq-twitter-integration.jar:../lib/hornetq-spring-integration.jar:../lib/hornetq-logging.jar:../lib/hornetq-jms.jar:../lib/hornetq-jms-client-java5.jar:../lib/hornetq-jms-client.jar:../lib/hornetq-jboss-as-integration.jar:../lib/hornetq-core.jar:../lib/hornetq-core-client-java5.jar:../lib/hornetq-core-client.jar:../lib/hornetq-bootstrap.jar:../lib/commons-logging.jar:../config/stand-alone/non-clustered:../schemas/ org.hornetq.integration.bootstrap.HornetQBootstrapServer hornetq-beans.xml
***********************************************************************************
* [main] 28-Nov 11:7:50,967 INFO [HornetQBootstrapServer]  Starting HornetQ Server
* [main] 28-Nov 11:7:51,753 INFO [HornetQServerImpl]  live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=../data/journal,bindingsDirectory=../data/bindings,largeMessagesDirectory=../data/large-messages,pagingDirectory=../data/paging)
* [main] 28-Nov 11:7:51,753 INFO [HornetQServerImpl]  Waiting to obtain live lock
* [main] 28-Nov 11:7:51,774 INFO [JournalStorageManager]  Using AIO Journal
* [main] 28-Nov 11:7:51,937 INFO [AIOFileLockNodeManager]  Waiting to obtain live lock
* [main] 28-Nov 11:7:51,937 INFO [AIOFileLockNodeManager]  Live Server Obtained live lock
* [main] 28-Nov 11:7:54,350 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.DLQ
* [main] 28-Nov 11:7:54,369 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.ExpiryQueue
* [main] 28-Nov 11:7:54,374 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.SomeQueue
* [main] 28-Nov 11:7:54,476 INFO [NettyAcceptor]  Started Netty Acceptor version 3.2.5.Final-a96d88c middleware-magic.com:4455 for CORE protocol
* [main] 28-Nov 11:7:54,477 INFO [NettyAcceptor]  Started Netty Acceptor version 3.2.5.Final-a96d88c middleware-magic.com:4445 for CORE protocol
* [main] 28-Nov 11:7:54,478 INFO [HornetQServerImpl]  Server is now live
* [main] 28-Nov 11:7:54,478 INFO [HornetQServerImpl]  HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [0ba4fa8d-3895-11e2-a23c-01d224a63402]) started

In order to test our set-up, we can use the following

package model.test;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

public class HornetQTest {

    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
        properties.put(Context.PROVIDER_URL, "jnp://192.168.1.150:1099");
        properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
        properties.put(Context.SECURITY_PRINCIPAL, "employee");
        properties.put(Context.SECURITY_CREDENTIALS, "welcome1");

        ConnectionFactory connectionFactory = null;
        Destination destination = null;

        try {
            Context context = new InitialContext(properties);
            connectionFactory = (ConnectionFactory) context.lookup("jms/SomeConnectionFactory");
            destination = (Destination) context.lookup("jms/queue/SomeQueue");

            System.out.println(connectionFactory);
            System.out.println(destination);

            sendMessage(connectionFactory, destination);
            receiveMessage(connectionFactory, destination);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    private static void sendMessage(ConnectionFactory connectionFactory, Destination destination) {
        Connection connection = null;
        Session session = null;
        MessageProducer messageProducer = null;

        try {
            connection = connectionFactory.createConnection("guest", "guest");
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            messageProducer = session.createProducer(destination);

            TextMessage text = session.createTextMessage();
            text.setText("Send some useful message");
            messageProducer.send(text);
        } catch (JMSException e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException f) {
                    f.printStackTrace();
                }
            }
        }
    }

    private static void receiveMessage(ConnectionFactory connectionFactory, Destination destination) {
        Connection connection = null;
        Session session = null;
        MessageConsumer messageConsumer = null;

        try {
            connection = connectionFactory.createConnection("guest", "guest");
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            messageConsumer = session.createConsumer(destination);

            connection.start();

            Message message = messageConsumer.receive(1000);
            System.out.println(message.getJMSDestination() + ", " + message);
            if (message instanceof TextMessage) {
                TextMessage text = (TextMessage) message;
                System.out.println(text.getText());
            }

            connection.stop();
        } catch (JMSException e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException f) {
                    f.printStackTrace();
                }
            }
        }
    }
}

To run this, we need jnpserver.jar on the class path. This jar can be obtained from the HornetQ distribution (${HORNETQ_HOME}/lib). The following output is observed when the program is run

HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=4445&host=middleware-magic-com], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]
HornetQQueue[SomeQueue]
HornetQQueue[SomeQueue], HornetQMessage[ID:e5d0ecc8-3944-11e2-b6cb-005056c00001]:PERSISTENT
Send some useful message

Make sure the host returned in this case middleware-magic-com can be resolved to the right IP address. More information can be found in the Spring and JBoss AS7 JMS post.

Set-up JBoss AS7

Next, we set-up the JBoss environment. To this end, we add the following to the domain.xml (located in the ${JBOSS_HOME}/domain/configuration directory)

<domain xmlns="urn:jboss:domain:1.1">
    <extensions>...</extensions>
    <system-properties>...</system-properties>
    <profiles>
        <profile name="standalone">...</profile>
        <profile name="cluster">
		    ...
            <subsystem xmlns="urn:jboss:domain:messaging:1.1">
                <hornetq-server>
                    <security-enabled>false</security-enabled>
                    <persistence-enabled>true</persistence-enabled>
                    <create-journal-dir>true</create-journal-dir>
                    <journal-type>ASYNCIO</journal-type>
                    <journal-buffer-timeout>500000</journal-buffer-timeout>
                    <journal-buffer-size>1048576</journal-buffer-size>
                    <journal-sync-transactional>true</journal-sync-transactional>
                    <journal-sync-non-transactional>true</journal-sync-non-transactional>
                    <journal-file-size>10485760</journal-file-size>
                    <journal-min-files>2</journal-min-files>
                    <journal-compact-min-files>10</journal-compact-min-files>
                    <journal-compact-percentage>30</journal-compact-percentage>
                    <journal-max-io>1024</journal-max-io>
                    <journal-directory path="data/messaging" relative-to="messaging.journal.base.directory"/>

                    <cluster-user>employee</cluster-user>
                    <cluster-password>welcome1</cluster-password>

                    <connectors>
                        <netty-connector name="netty" socket-binding="messaging"/>
                        <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                            <param key="batch-delay" value="50"/>
                        </netty-connector>
                        <in-vm-connector name="in-vm" server-id="0"/>
                    </connectors>

                    <acceptors>
                        <netty-acceptor name="netty" socket-binding="messaging"/>
                        <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                            <param key="batch-delay" value="50"/>
                            <param key="direct-deliver" value="false"/>
                        </netty-acceptor>
                        <in-vm-acceptor name="in-vm" server-id="0"/>
                    </acceptors>

                    <security-settings>
                        <security-setting match="#">
                            <permission type="send" roles="guest"/>
                            <permission type="consume" roles="guest"/>
                            <permission type="createNonDurableQueue" roles="guest"/>
                            <permission type="deleteNonDurableQueue" roles="guest"/>
                        </security-setting>
                    </security-settings>

                    <address-settings>
                        <address-setting match="#">
                            <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                            <expiry-address>jms.queue.EQ</expiry-address>
                            <redelivery-delay>0</redelivery-delay>
                            <max-size-bytes>10485760</max-size-bytes>
                            <address-full-policy>BLOCK</address-full-policy>
                            <message-counter-history-day-limit>10</message-counter-history-day-limit>
                        </address-setting>
                        <address-setting match="jms.queue.testQueue">
                            <dead-letter-address>jms.queue.deadLetterQueue</dead-letter-address>
                            <expiry-address>jms.queue.expiryQueue</expiry-address>
                            <redelivery-delay>5000</redelivery-delay>
                            <max-delivery-attempts>3</max-delivery-attempts>
                            <max-size-bytes>104857600</max-size-bytes>
                            <address-full-policy>BLOCK</address-full-policy>
                            <last-value-queue>true</last-value-queue>
                            <redistribution-delay>0</redistribution-delay>
                            <send-to-dla-on-no-route>true</send-to-dla-on-no-route>
                        </address-setting>
                    </address-settings>

                    <jms-connection-factories>
                        <connection-factory name="InVmConnectionFactory">
                            <connectors>
                                <connector-ref connector-name="in-vm"/>
                            </connectors>
                            <entries>
                                <entry name="java:/ConnectionFactory"/>
                            </entries>
                        </connection-factory>
                        <connection-factory name="RemoteConnectionFactory">
                            <connectors>
                                <connector-ref connector-name="netty"/>
                            </connectors>
                            <entries>
                                <entry name="RemoteConnectionFactory"/>
                                <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                            </entries>
                        </connection-factory>
                        <pooled-connection-factory name="hornetq-ra">
                            <transaction mode="xa"/>
                            <connectors>
                                <connector-ref connector-name="in-vm"/>
                            </connectors>
                            <entries>
                                <entry name="java:/JmsXA"/>
                            </entries>
                        </pooled-connection-factory>
                    </jms-connection-factories>

                    <jms-destinations>
                        <jms-queue name="testQueue">
                            <entry name="java:/queue/test"/>
                            <entry name="java:jboss/exported/jms/queue/test"/>
                        </jms-queue>
                        <jms-queue name="deadLetterQueue">
                            <entry name="java:/queue/deadLetterQueue"/>
                            <entry name="java:jboss/exported/jms/queue/deadLetterQueue"/>
                            <durable>false</durable>
                        </jms-queue>
                        <jms-queue name="expiryQueue">
                            <entry name="java:/queue/expiryQueue"/>
                            <entry name="java:jboss/exported/jms/queue/expiryQueue"/>
                            <durable>false</durable>
                        </jms-queue>
                        <jms-topic name="testTopic">
                            <entry name="java:/topic/test"/>
                            <entry name="java:jboss/exported/jms/topic/test"/>
                        </jms-topic>
                    </jms-destinations>
                </hornetq-server>
            </subsystem>
			...
        </profile>
    </profiles>
    <interfaces>...</interfaces>
    <socket-binding-groups>...</socket-binding-groups>
    <deployments>
        <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear">
            <content sha1="161f51dde7f085c822cc4c68b306d57f1bee902d"/>
        </deployment>
        <deployment name="SpringHibernate.war" runtime-name="SpringHibernate.war">
            <content sha1="7d11daad8702ecc31321f41089b32ded945c6d7f"/>
        </deployment>
    </deployments>
    <server-groups>
        <server-group name="standalone-group" profile="standalone">
            <jvm name="default"/>
            <socket-binding-group ref="standalone-sockets"/>
        </server-group>
        <server-group name="cluster-group" profile="cluster">
            <jvm name="default"/>
            <socket-binding-group ref="cluster-sockets"/>
            <deployments>
                <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear" enabled="false"/>
                <deployment name="SpringHibernate.war" runtime-name="SpringHibernate.war"/>
            </deployments>
        </server-group>
    </server-groups>
</domain>

In the host.xml we have the following

<host name="jboss" xmlns="urn:jboss:domain:1.1">
    <management>...</management>
    <domain-controller><local/></domain-controller>
    <interfaces>...</interfaces>
    <jvms>
    	<jvm name="default">
            <heap size="512m" max-size="512m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-XX:NewRatio=2"/>
                <option value="-XX:+UseParallelGC"/>
                <option value="-XX:ParallelGCThreads=2"/>
                <option value="-XX:MaxGCPauseMillis=200"/>
                <option value="-XX:GCTimeRatio=19"/>
                <option value="-XX:+UseParallelOldGC"/>
                <option value="-XX:+UseTLAB"/>
                <option value="-XX:LargePageSizeInBytes=2048k"/>
                <option value="-XX:+UseLargePages"/>
            </jvm-options>
        </jvm>
    </jvms>
    <servers>
        <server name="standalone-server" group="standalone-group" auto-start="false"/>
        <server name="cluster-server1" group="cluster-group" auto-start="false">
            <paths>
                <path name="messaging.journal.base.directory" path="/home/jboss/temp/cluster-server1"/>
            </paths>
        </server>
        <server name="cluster-server2" group="cluster-group" auto-start="false">
            <socket-bindings port-offset="1"/>
            <paths>
                <path name="messaging.journal.base.directory" path="/home/jboss/temp/cluster-server2"/>
            </paths>
        </server>
    </servers>
</host>

Note that we have also configured the messaging journal in the domain.xml

  • journal-directory – This is the directory in which the message journal lives. For the best performance, it is recommended that the journal is located on its own physical volume in order to minimise disk head movement. If the journal is on a volume which is shared with other processes which might be writing other files (e.g. bindings journal, database, or transaction coordinator) then the disk head may well be moving rapidly between these files as it writes them, thus drastically reducing performance. When the message journal is stored on a SAN it is recommended that each journal instance that is stored on the SAN is given its own LUN (logical unit).
  • create-journal-dir – If this is set to true then the journal directory will be automatically created at the location specified in journal-directory if it does not already exist.
  • journal-type – Valid values are NIO or ASYNCIO. The NIO option uses the Java NOI Journal. The ASYNCIO option uses the Linux asynchronous IO journal. If we choose ASYNCIO and are not running Linux or do not have libaio installed then HornetQ will detect this and automatically fall back to using NIO. The ASYNCIO option uses a thin native code wrapper to talk to the Linux asynchronous IO library (AIO). With AIO, HornetQ will be called back when the data has made it to disk, allowing HornetQ to avoid explicit syncs altogether and simply send back confirmation of completion when AIO informs HornetQ that the data has been persisted. Using AIO will typically provide better performance than using Java NIO.
  • journal-sync-transactional – If this is set to true then HornetQ will make sure all transaction data is flushed to disk on transaction boundaries (commit, prepare and rollback).
  • journal-sync-non-transactional – If this is set to true then HornetQ will make sure non transactional message data (sends and acknowledgements) are flushed to disk each time.
  • journal-file-size – The size of each journal file in bytes.
  • journal-min-files – The minimum number of files the journal will maintain. When HornetQ starts and there is no initial message data, HornetQ will pre-create journal-min-files number of files. Creating journal files and filling them with padding is a fairly expensive operation and we want to minimise doing this at run-time as files get filled. By precreating files, as one is filled the journal can immediately resume with the next one without pausing to create it. Depending on how much data we expect our queues to contain at steady state we should tune this number of files to match that total amount of data.
  • journal-max-io – Write requests are queued up before being submitted to the system for execution. This parameter controls the maximum number of write requests that can be in the IO queue at any one time. If the queue becomes full then writes will block until space is freed up. When using NIO, this value should always be equal to 1. When using ASYNCIO, the default value is 500. The maximum value of ASYNCIO can not be higher than the value configured in the operating system (i.e., /proc/sys/fs/aio-max-nr).
  • journal-buffer-timeout – Instead of flushing on every write that requires a flush, HornetQ maintains an internal buffer, and flush the entire buffer either when it is full, or when a timeout expires. This allows the system to scale better with many concurrent writes that require flushing. Note that The second implementation uses a thin native code wrapper to talk to the Linux asynchronous IO library (AIO). With AIO, HornetQ will be called back when the data has made it to disk, allowing us to avoid explicit syncs altogether and simply send back confirmation of completion when AIO informs us that the data has been persisted. Note that ASYNCIO can cope with a higher flush rate than NIO (the default values are 3333333 nanoseconds (300 times per second) for NOI and 500000 nanoseconds (2000 times per second) for ASYNCIO.
  • journal-buffer-size – The size of the buffer.
  • journal-compact-min-files – The minimal number of files before HornetQ can consider compacting the journal. The compacting algorithm will not start until there are at least journal-compact-min-files.
  • journal-compact-percentage – The threshold to start compacting. When less than this percentage is considered live data, HornetQ starts compacting.

For the testQueue we have also specified address settings

  • max-delivery-attempts – defines how many times a cancelled message can be redelivered before sending to the dead-letter-address.
  • redelivery-delay – defines how long to wait before attempting redelivery of a cancelled message.
  • expiry-address defines where to send a message that has expired (the time is set by using a time-to-live).
  • last-value-queue – defines whether a queue only uses last values or not. Last-Value queues are special queues which discard any messages when a newer message with the same value for a well-defined Last-Value property is put in the queue.
  • redistribution-delay – defines how long to wait when the last consumer is closed on a queue before redistributing any messages. Server side message load balancing round robins messages across the cluster. If forward-when-no-consumers is false, then messages will not be forwarded to nodes which do not have matching consumers, this is great and ensures that messages do not arrive on a queue which has no consumers to consume them, however there is a situation it does not solve: What happens if the consumers on a queue close after the messages have been sent to the node? If there are no consumers on the queue the message will not get consumed and we have a starvation situation. This is where message redistribution comes in. With message redistribution HornetQ can be configured to automatically redistribute messages from queues which have no consumers back to other nodes in the cluster which do have matching consumers. Message redistribution can be configured to kick in immediately after the last consumer on a queue is closed, or to wait a configurable delay after the last consumer on a queue is closed before redistributing.
  • send-to-dla-on-no-route – if a message is sent to an address, but the server does not route it to any queues, for example, there might be no queues bound to that address, or none of the queues have filters that match, then normally that message would be discarded. However if this parameter is set to true for that address, if the message is not routed to any queues it will instead be sent to the dead letter address for that address, if it exists.
  • address-full-policy – this attribute can have one of the following values: PAGE, DROP or BLOCK and determines what happens when an address where max-size-bytes is specified becomes full. If the value is PAGE then further messages will be paged to disk. If the value is DROP then further messages will be silently dropped. If the value is BLOCK then client message producers will block when they try and send further messages.

To test the JBoss side, we can use

package model.test;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

public class JNDITest {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        properties.put(Context.PROVIDER_URL, "remote://192.168.1.150:4447");
        properties.put(Context.SECURITY_PRINCIPAL, "employee");
        properties.put(Context.SECURITY_CREDENTIALS, "welcome1");

        ConnectionFactory connectionFactory = null;
        Destination destination = null;

        try {
            Context context = new InitialContext(properties);
            connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
            destination = (Destination) context.lookup("jms/queue/test");

            System.out.println(connectionFactory);
            System.out.println(destination);

            sendMessage(connectionFactory, destination);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    private static void sendMessage(ConnectionFactory connectionFactory, Destination destination) {
        Connection connection = null;
        Session session = null;
        MessageProducer messageProducer = null;

        try {
            connection = connectionFactory.createConnection("employee", "welcome1");
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            messageProducer = session.createProducer(destination);

            TextMessage text = session.createTextMessage();
            text.setText("Send some useful message");
            messageProducer.send(text);
        } catch (JMSException e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException f) {
                    f.printStackTrace();
                }
            }
        }
    }
}

To run this we need jboss-client-7.1.0.Final.jar in the class path. When the program is run the following is observed on the client side

Nov 28, 2012 1:48:05 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Nov 28, 2012 1:48:05 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Nov 28, 2012 1:48:05 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.2.GA
HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=middleware-magic-com], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]
HornetQQueue[testQueue]

On the server side (in the JBoss logging) the following is observed

13:48:07,450 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED TEXT MESSAGE Send some useful message
13:48:07,502 INFO  [org.jboss.as.naming] (Remoting "jboss:cluster-server1" task-4) JBAS011806: Channel end notification received, closing channel Channel ID 3df88b53 (inbound) of Remoting connection 08fa0f67 to null

The message is picked-up by the Spring/Hibernate application introduced in the Spring and Hibernate4 post.

Monitoring

HermesJMS is an extensible console that helps you interact with JMS providers making it simple to publish and edit messages, browse or seach queues and topics, copy messages around and delete them. By using HermesJMS we are able to browse destinations:

  • Edit the file hermes.sh located in the directory <HermesJMS-Home>/bin.
  • Make sure the variable JAVA_HOME points to a valid JDK installation directory.
  • Run the file hermes.sh.
  • Click in the menu on options, configuration.
  • Click on the providers tab at the bottom.
  • Right click on classpath groups and select add group.
  • Enter a name, for example JBossAS7.
  • Click on the + to expand the JBossAS7 tree, right click library and select add jar(s).
  • Browse to ${JBOSS_HOME}/bin/client and select jboss-client-7.1.0.jar.
  • Click do not scan and click ok.
  • Right click sessions and select new, new session.
  • In the connection factory section enter the following parameters:
    • class: hermes.JNDIConnectionFactory
    • loader: JBossAS7 (this is the provider we create above)
  • Subsequently, add some properties (right click under property and choose from the drop-down-box)
    • securityCredentials: welcome1 (password of an application user with guest as role)
    • initialContextFactory: org.jboss.naming.remote.client.InitialContextFactory
    • securityPrincipal: employee (username of an application user with guest as role)
    • binding: jms/RemoteConnectionFactory (a connection factory configured on the server, which has a prefix java:jboss/exported)
    • providerURL: remote://192.168.1.150:4447 (url to the server)
    • urlPkgPrefixes: org.jboss.naming.remote.client
  • Add the destination that we want to monitor in the destinations section (right click and choose add)
    • name: JNDI name of the destination, for example, jms/queue/test
  • Click ok.
  • Double click the MiddlewareMagic session to browse the destination.

In hermes-config.xml the following has been added

...
<classpathGroup id="jbossas7">
	<library factories="org.hornetq.jms.client.HornetQJMSConnectionFactory,org.hornetq.jms.client.HornetQQueueConnectionFactory,org.hornetq.jms.client.HornetQTopicConnectionFactory,org.hornetq.jms.client.HornetQXAConnectionFactory,org.hornetq.jms.client.HornetQXAQueueConnectionFactory,org.hornetq.jms.client.HornetQXATopicConnectionFactory" noFactories="false" jar="/home/jboss/jboss-as-7.1.0.Final/bin/client/jboss-client-7.1.0.Final.jar"/>
</classpathGroup>
...
<factory classpathId="jbossas7">
	<provider className="hermes.JNDIConnectionFactory">
		<properties>
			<property value="jms/RemoteConnectionFactory" name="binding"/>
			<property value="org.jboss.naming.remote.client.InitialContextFactory" name="initialContextFactory"/>
			<property value="remote://192.168.1.150:4447" name="providerURL"/>
			<property value="welcome1" name="securityCredentials"/>
			<property value="employee" name="securityPrincipal"/>
			<property value="org.jboss.naming.remote.client" name="urlPkgPrefixes"/>
		</properties>
	</provider>
	<connection connectionPerThread="false" clientID="">
		<session useConsumerForQueueBrowse="false" audit="false" transacted="true" reconnects="0" id="&lt;new&gt;"/>
	</connection>
	<destination durable="false" domain="1" name="jms/queue/test"/>
	<extension className="hermes.ext.DefaultHermesAdminFactory">
		<properties/>
	</extension>
</factory>
...

An example output after sending a message

Create the Bridge

Our next goal is to forward messages put into the HornetQ queue (by, for example, the client introduced above) by using a HornetQ bridge. The HornetQ bridge will forward the messages to the JBoss Server. To configure the bridge we can use the following in the hornetq-configuration.xml file

<configuration ...>
	...
	<connectors>
		...
		<connector name="remote-connector">
			<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
			<param key="host"  value="${hornetq.remoting.netty.host:middleware-magic.com}"/>
			<param key="port"  value="${hornetq.remoting.netty.batch.port:5445}"/>
		</connector>
	</connectors>
	<acceptors>...</acceptors>
	<queues>
		<queue name="jms.queue.SomeQueue">
			<address>jms.queue.SomeQueue</address>
		</queue>
	</queues>
	<bridges>
		<bridge name="SomeBridge">
			<queue-name>jms.queue.SomeQueue</queue-name>
			<forwarding-address>jms.queue.testQueue</forwarding-address>
			<reconnect-attempts>-1</reconnect-attempts>
			<static-connectors>
				<connector-ref>remote-connector</connector-ref>
			</static-connectors>
		</bridge>
	</bridges>
	<security-settings>...</security-settings>
	<address-settings>...</address-settings>
</configuration>

As we are connecting to a JBoss Server we need some extra classes in the class path of the HornetQ Server that are contained in the jboss-client-7.1.0.Final.jar file. With the configuration in place start the HornetQ Server

[jboss@middleware-magic bin]$ ./run.sh
***********************************************************************************
java  -XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M -Dhornetq.config.dir=../config/stand-alone/non-clustered -Djava.util.logging.config.file=../config/stand-alone/non-clustered/logging.properties -Djava.library.path=. -classpath ../lib/twitter4j-core.jar:../lib/netty.jar:../lib/jnpserver.jar:../lib/jnp-client.jar:../lib/jboss-mc.jar:../lib/jboss-jms-api.jar:../lib/jboss-client-7.1.0.Final.jar:../lib/hornetq-twitter-integration.jar:../lib/hornetq-spring-integration.jar:../lib/hornetq-logging.jar:../lib/hornetq-jms.jar:../lib/hornetq-jms-client-java5.jar:../lib/hornetq-jms-client.jar:../lib/hornetq-jboss-as-integration.jar:../lib/hornetq-core.jar:../lib/hornetq-core-client-java5.jar:../lib/hornetq-core-client.jar:../lib/hornetq-bootstrap.jar:../config/stand-alone/non-clustered:../schemas/ org.hornetq.integration.bootstrap.HornetQBootstrapServer hornetq-beans.xml
***********************************************************************************
* [main] 28-Nov 14:2:49,29 INFO [HornetQBootstrapServer]  Starting HornetQ Server
* [main] 28-Nov 14:2:50,964 INFO [HornetQServerImpl]  live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=../data/journal,bindingsDirectory=../data/bindings,largeMessagesDirectory=../data/large-messages,pagingDirectory=../data/paging)
* [main] 28-Nov 14:2:50,964 INFO [HornetQServerImpl]  Waiting to obtain live lock
* [main] 28-Nov 14:2:50,985 INFO [JournalStorageManager]  Using AIO Journal
* [main] 28-Nov 14:2:51,173 INFO [AIOFileLockNodeManager]  Waiting to obtain live lock
* [main] 28-Nov 14:2:51,173 INFO [AIOFileLockNodeManager]  Live Server Obtained live lock
* [main] 28-Nov 14:2:53,787 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.SomeQueue
* [main] 28-Nov 14:2:53,851 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.DLQ
* [main] 28-Nov 14:2:53,871 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.ExpiryQueue
* [main] 28-Nov 14:2:53,876 INFO [HornetQServerImpl]  trying to deploy queue jms.queue.SomeQueue
* [main] 28-Nov 14:2:54,57 INFO [NettyAcceptor]  Started Netty Acceptor version 3.2.5.Final-a96d88c middleware-magic.com:4455 for CORE protocol
* [main] 28-Nov 14:2:54,59 INFO [NettyAcceptor]  Started Netty Acceptor version 3.2.5.Final-a96d88c middleware-magic.com:4445 for CORE protocol
* [main] 28-Nov 14:2:54,343 INFO [HornetQServerImpl]  Server is now live
* [main] 28-Nov 14:2:54,344 INFO [HornetQServerImpl]  HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [0ba4fa8d-3895-11e2-a23c-01d224a63402]) started

* [Thread-3 (HornetQ-server-HornetQServerImpl::serverUUID=0ba4fa8d-3895-11e2-a23c-01d224a63402-1332226643)] 28-Nov 14:2:58,112 INFO [BridgeImpl]  Bridge BridgeImpl@7b712193 [name=SomeBridge, queue=QueueImpl[name=jms.queue.SomeQueue, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=0ba4fa8d-3895-11e2-a23c-01d224a63402]]@40537935 targetConnector=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=middleware-magic-com], discoveryGroupConfiguration=null]] is connected

* [Thread-1 (HornetQ-client-global-threads-851009394)] 28-Nov 15:35:13,698 WARNING [RemotingConnectionImpl]  Connection failure has been detected: The connection was disconnected because of server shutdown [code=4]
* [Thread-1 (HornetQ-client-global-threads-851009394)] 28-Nov 15:35:13,699 WARNING [BridgeImpl]  BridgeImpl@7b712193 [name=SomeBridge, queue=QueueImpl[name=jms.queue.SomeQueue, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=0ba4fa8d-3895-11e2-a23c-01d224a63402]]@40537935 targetConnector=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=middleware-magic-com], discoveryGroupConfiguration=null]]::Connection failed with failedOver=false-HornetQException[errorCode=4 message=The connection was disconnected because of server shutdown]
HornetQException[errorCode=4 message=The connection was disconnected because of server shutdown]
	at org.hornetq.core.client.impl.ClientSessionFactoryImpl$Channel0Handler$1.run(ClientSessionFactoryImpl.java:1467)
	at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

* [Thread-29 (HornetQ-server-HornetQServerImpl::serverUUID=0ba4fa8d-3895-11e2-a23c-01d224a63402-1332226643)] 28-Nov 15:36:17,997 INFO [BridgeImpl]  Bridge BridgeImpl@7b712193 [name=SomeBridge, queue=QueueImpl[name=jms.queue.SomeQueue, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=0ba4fa8d-3895-11e2-a23c-01d224a63402]]@40537935 targetConnector=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=middleware-magic-com], discoveryGroupConfiguration=null]] is connected

As the last logging line indicates, we are connected. Note that the logging also shows what happens when the JBoss servers are shutdown and started (disconnect and connect). Running the client a few times leads to in the JBoss Server log.

14:04:06,384 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED TEXT MESSAGE Send some useful message
14:04:11,950 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED TEXT MESSAGE Send some useful message
14:04:17,943 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED TEXT MESSAGE Send some useful message
14:04:20,462 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED TEXT MESSAGE Send some useful message

Performance

When running a JMS system some performance tweaks could be necessary, such as

When dealing with large message flows, it is beneficial to put as many messages in the JVM heap as possible. Or better yet, just put them all in the JVM heap, sometimes this leads to creating very large heaps (with of course garbage collection as a very potential bottleneck). Usually, when using the common JVMs, such as HotSpot, garbage collection becomes a bottleneck. When dealing with very large heaps it shows beneficial to use the Zing JVM (created by Azul Systems) instead.

References

[1] HornetQ User Manual.
[2] Performance Tuning.


Spring and Hibernate4

In this post we put Spring and Hibernate 4 together. We start out by creating a Java client to see what is needed to make things work. Next, we create a Web application (by adding a servlet) and deploy the application to JBoss AS7 (and use the native Hibernate API). Here, we show what needs to be done in order to make Spring and the native Hibernate API work together on the JBoss Application Server, i.e., we create an extra module (org.springframework) and make sure this is loaded by the deployed Web module. Finally, we show how to include messaging as well. More information on how the JBoss environment is set-up can be found in the post Building a Coherence Cluster with Multiple Application Servers. We also show how the environment can be migrated from JBoss to WebLogic (or vice versa). More information about the WebLogic environment can be found in the post Deploy WebLogic12c to Multiple Machines.

Client

Let us start by creating a Java client, just to get a feeling of what needs to be done and not have the complexity of a Java EE Server (such as, for example, JBoss AS7) along with it. To this end we can use the following Spring configuration

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
    <bean id="company" class="model.logic.CompanyBean">
        <property name="sessionFactory" ref="sessionfactory"/>
    </bean>
    <bean id="sessionfactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="datasource"/>
        <!--property name="jtaTransactionManager" ref="transactionManager"/-->
        <property name="mappingResources">
            <list>
                <value>model/entities/person.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <!--prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop-->
                <prop key="hibernate.listeners.envers.autoRegister">${hibernate.listeners.envers.autoRegister}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            </props>
        </property>
    </bean>
    <!--jee:jndi-lookup id="datasource" jndi-name="java:/jdbc/OracleDS" resource-ref="false"/-->
    <bean id="datasource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
        <property name="driverType" value="${jdbc.driverClassName}"/>
        <property name="URL" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:spring.properties</value>
            </list>
        </property>
    </bean>
    <!--bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/-->
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionfactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

Note that we did not set the hibernate.current_session_context_class property. We should never use that property when combining Hibernate with Spring as it destroys proper session and transaction management when using the HibernateTransactionManager. On the other hand, when on a Java EE Server and using the JtaTransactionManager, set the property to the value thread. Another thing to note is that the EnversIntegrator is always detected by default while initializing the ServiceRegistry using the Native Hibernate API causing a MappingException even when Envers is not used when deployed on JBoss AS7. That is why we have set the value of the hibernate.listeners.envers.autoRegister property to false.

The contents of the referred spring.properties look as follows

jdbc.driverClassName=oracle.jdbc.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.1.60:1521:orcl11
jdbc.username=example
jdbc.password=example

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.current_session_context_class=thread
hibernate.listeners.envers.autoRegister=false
hibernate.show_sql=false
hibernate.format_sql=false

The CompanyBean class looks as follows

package model.logic;

import model.entities.Person;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class CompanyBean implements Company {

    private SessionFactory sessionFactory;

    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    public void insertPerson(Person person) {
        Person temporaryPerson = findPerson(person.getSofinummer());
        if (temporaryPerson == null) {
            System.out.println("INSERT " + person);
            getCurrentSession().save(person);
        } else {
            updatePerson(person);
        }
    }

    public void removePerson(Integer sofinummer) {
        Person temporaryPerson = findPerson(sofinummer);
        if (temporaryPerson != null) {
            System.out.println("REMOVE " + temporaryPerson);
            getCurrentSession().delete(temporaryPerson);
        }
    }

    public void updatePerson(Person person) {
        System.out.println("UPDATE " + person);
        getCurrentSession().merge(person);
    }

    private Person findPerson(Integer sofinummer) {
        return (Person) getCurrentSession().get(Person.class, sofinummer);
    }

    private final Session getCurrentSession(){
      return getSessionFactory().getCurrentSession();
   }
}

To test the set-up, we can use something like

package model.test;

import model.entities.Person;
import model.logic.Company;
import model.utils.SpringUtilities;

import java.util.Random;

public class Test {

    private Random generator = new Random();

    public static void main(String[] args) {
        Test test = new Test();

        Company company = SpringUtilities.getCompany();

        for (int i = 0; i &lt; 100; i++) {
            Person person = test.createPerson();
            if (test.generator.nextDouble() &lt; 0.01) {
                company.removePerson(person.getSofinummer());
            } else {
                company.insertPerson(person);
            }
        }
    }

    private Person createPerson() {
        Person person = new Person();
        person.setNaam(Long.toString(Math.abs(generator.nextLong()), 36));
        person.setSofinummer(generator.nextInt(10000));
        return person;
    }
}

When the test is run something like the following output is observed

Aug 14, 2012 2:59:35 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@145d068: startup date [Tue Aug 14 14:59:35 CEST 2012]; root of context hierarchy
Aug 14, 2012 2:59:35 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config.xml]
Aug 14, 2012 2:59:36 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [spring.properties]
Aug 14, 2012 2:59:36 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1faba46: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor]; root of factory hierarchy
Aug 14, 2012 2:59:36 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Aug 14, 2012 2:59:36 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.2.Final}
Aug 14, 2012 2:59:36 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 14, 2012 2:59:36 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 14, 2012 2:59:36 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Aug 14, 2012 2:59:36 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
Aug 14, 2012 2:59:36 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Aug 14, 2012 2:59:36 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Aug 14, 2012 2:59:36 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.0.Final
Aug 14, 2012 2:59:36 PM org.springframework.orm.hibernate4.HibernateTransactionManager afterPropertiesSet
INFO: Using DataSource [oracle.jdbc.pool.OracleDataSource@161f39e] of Hibernate SessionFactory for HibernateTransactionManager
UPDATE 179arxyy6tshk 6176
INSERT 1sf4e5oz89uhi 2402
UPDATE t9pjpfnqxc4k 8413
UPDATE 1ckym7ttz46mf 5246
UPDATE 1u7litwyaigu4 1211
INSERT 74ra63w7aql6 2238
INSERT 5v48tzzk75qo 5902
INSERT mh5zpr30rjkd 2082
UPDATE 13xzu6r3g0ruz 5877
UPDATE 1jeqjhlfjwv81 9332
INSERT 19zb01tagisqq 6022
INSERT q5v1re6g6svp 3071
INSERT 12t5tsoyld5nl 9991
INSERT m7dhwiwvx7oi 9089
INSERT 1hz8k3rq1cngf 5596
UPDATE 14hhycu8lxban 4169
INSERT 4hh6749zjr67 2970
INSERT 143ofpk3kupmn 8769
UPDATE 16cfhq1shjzu7 8439
UPDATE scijv0dgh6m4 4234

Server

When we want to run the application on a Java EE Server, such as JBoss AS7, we can use the JtaTransactionManager instead of the HibernateTransactionManager. We also get a reference to a datasource by looking it up in JNDI, i.e.,

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
    <bean id="company" class="model.logic.CompanyBean">
        <property name="sessionFactory" ref="sessionfactory"/>
    </bean>
    <bean id="sessionfactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="datasource"/>
        <property name="jtaTransactionManager" ref="transactionManager"/>
        <property name="mappingResources">
            <list>
                <value>model/entities/person.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
                <prop key="hibernate.listeners.envers.autoRegister">${hibernate.listeners.envers.autoRegister}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            </props>
        </property>
    </bean>
    <jee:jndi-lookup id="datasource" jndi-name="java:/jdbc/OracleDS" resource-ref="false"/>
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:spring.properties</value>
            </list>
        </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
    <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

To test the configuration we can use the following servlet

package userinterface.servlets;

import model.entities.Person;
import model.logic.Company;
import model.utils.SpringUtilities;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Random;

@WebServlet(name = "TestServlet", urlPatterns = "/testservlet")
public class TestServlet extends HttpServlet {

    private Random generator = null;
    private Company company = null;

    @Override
    public void init() throws ServletException {
        generator = new Random();
        company = SpringUtilities.getCompany();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Person person = createPerson();

        if (generator.nextDouble() &lt; 0.01) {
            company.removePerson(person.getSofinummer());
        } else {
            company.insertPerson(person);
        }
    }

    @Override
    public void destroy() {
        generator = null;
        company = null;
    }

    private Person createPerson() {
        Person person = new Person();
        person.setNaam(Long.toString(Math.abs(generator.nextLong()), 36));
        person.setSofinummer(generator.nextInt(10000));
        return person;
    }
}

One thing to note is that when we need to develop a servlet (by using an IDE) we have to make sure the right classes are on the classpath. Usually, when developing a Java EE application the javaee-api-6.0.jar would suffice. One thing to note is that if we were to run our Test class again we would run into the following: Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation. To resolve this we need the full implementation of the bean-validator.jar on the classpath and make sure that it is loaded before the javaee-api-6.0.jar.

Before, we can deploy the application we have to make sure the Spring classes are picked up by the Web module. To this end, we create the following module on JBoss AS7. First, create a directory structure that includes the necessary jars and a module.xml file as follows

${JBOSS_HOME}/modules
	/org/springframework
		/main
			aopalliance-1.0.jar
			cglib-2.2.2.jar
			commons-logging-1.0.4.jar
			module.xml
			org.springframework.aop-3.1.2.RELEASE.jar
			org.springframework.asm-3.1.2.RELEASE.jar
			org.springframework.beans-3.1.2.RELEASE.jar
			org.springframework.context-3.1.2.RELEASE.jar
			org.springframework.core-3.1.2.RELEASE.jar
			org.springframework.expression-3.1.2.RELEASE.jar
			org.springframework.jdbc-3.1.2.RELEASE.jar
			org.springframework.jms-3.1.2.RELEASE.jar
			org.springframework.orm-3.1.2.RELEASE.jar
			org.springframework.transaction-3.1.2.RELEASE.jar
			org.springframework.web-3.1.2.RELEASE.jar

where module.xml has the following contents

<module xmlns="urn:jboss:module:1.1" name="org.springframework">
    <resources>
		<resource-root path="aopalliance-1.0.jar"/>
		<resource-root path="cglib-2.2.2.jar"/>
		<resource-root path="commons-logging-1.0.4.jar"/>
		<resource-root path="org.springframework.aop-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.asm-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.beans-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.context-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.core-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.expression-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.jdbc-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.jms-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.orm-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.transaction-3.1.2.RELEASE.jar"/>
		<resource-root path="org.springframework.web-3.1.2.RELEASE.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api" export="true"/>
        <module name="org.apache.log4j" export="true"/>
        <module name="org.antlr" export="true"/>
        <module name="org.dom4j" export="true"/>
        <module name="org.hibernate" export="true"/>
        <module name="javax.persistence.api" export="true"/>
        <module name="org.javassist" export="true"/>
        <module name="org.jboss.logging" export="true"/>
        <module name="javax.transaction.api" export="true"/>
    </dependencies>
</module>

Note that we also have included a Hibernate dependency (as this is needed by Spring when using Hibernate with it). To make sure we have all the required files, we can check a Hibernate 4 distribution and look in the ${HIBERNATE_HOME}/lib/required directory. That is, we need the following jars:

antlr-2.7.7.jar (loaded by adding the module org.antlr)
dom4j-1.6.1.jar (loaded by adding the module org.dom4j)
hibernate-commons-annotations-4.0.1.Final.jar (loaded by adding the module org.hibernate)
hibernate-core-4.0.1.Final.jar (loaded by adding the module org.hibernate)
hibernate-jpa-2.0-api-1.0.1.Final.jar (loaded by adding the module javax.persistence.api)
javassist-3.15.0-GA.jar (loaded by adding the module org.javassist)
jboss-logging-3.1.0.GA.jar (loaded by adding the module org.jboss.logging)
jboss-transaction-api_1.1_spec-1.0.0.Final.jar (loaded by adding the module javax.transaction.api)

Another important module that Spring depends on is the javax.api, as Spring needs XML related classes, such as parsers. Note that JBoss AS7 does not make javax packages, that are present in rt.jar, available. To make this happen we need to include the javax.api module. One important thing to note is that the javax.api module does not include a reference to javax.xml.parsers. To this end, edit the module.xml (located in the ${JBOSS_HOME}/modules/javax/api/main directory) and make sure that it does, i.e.,

<module xmlns="urn:jboss:module:1.1" name="javax.api">
    <dependencies>
        <system export="true">
            <paths>
				...
				<!-- To resolve java.lang.ClassNotFoundException: javax.xml.parsers.ParserConfigurationException from [Module "org.springframework:main" from local module loader @2393385d (roots: /home/jboss/jboss-as-7.1.0.Final/modules)] we have to add -->
                <path name="javax/xml/parsers"/>
				...
				<!-- java.lang.ClassNotFoundException: org.xml.sax.EntityResolver from [Module "org.springframework:main" from local module loader @2393385d (roots: /home/jboss/jboss-as-7.1.0.Final/modules)] is the first ClassNotFoundException we run into if the javax.api module is not added as a dependency to the org.springframework module -->
                <path name="org/xml/sax"/>
                <path name="org/xml/sax/ext"/>
                <path name="org/xml/sax/helpers"/>
            </paths>
        </system>
    </dependencies>
</module>

With the modules in place, restart the servers to make sure the modules are loaded

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin/

[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.

[disconnected /] connect 192.168.1.150:9999

[domain@192.168.1.150:9999 /] /host=jboss/server-config=cluster-server1:restart
{
    "outcome" => "success",
    "result" => "STARTING"
}
[domain@192.168.1.150:9999 /] /host=jboss/server-config=cluster-server2:restart
{
    "outcome" => "success",
    "result" => "STARTING"
}

As we are dealing with a .war deployment, we have to add the jboss-deployment-structure.xml file to the WEB-INF directory, such that the org.springframework module can be accessed by the Web module. The contents of jboss-deployment-structure.xml look as follows

<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.springframework">
				<imports>
					<include path="META-INF**"/>
					<include path="org**"/>
				</imports>
			</module>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

The imports element above is critical for the proper functioning of the Spring custom name-space capabilities. Applications that use custom name-spaces and wish to use a shared Spring module must use the JBoss deployment structure descriptors with the imports above. To deploy the application we can use

[domain@192.168.1.150:9999 /] deploy /home/jboss/jboss-as-7.1.0.Final/deploy/springhibernate/SpringHibernate.war --server-groups=cluster-group
[domain@192.168.1.150:9999 /] undeploy SpringHibernate.war --server-groups=cluster-group

which also shows how to undeploy it. The application can be reached at http://192.168.1.150:8888/SpringHibernate/testservlet. After doing a few requests the following is observed in the logging:

# LOGGING CLUSTER_SERVER1
12:52:50,289 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp--192.168.1.150-9080-3) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@876e4b8: startup date [Tue Aug 14 12:52:50 CEST 2012]; root of context hierarchy
12:52:50,294 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp--192.168.1.150-9080-3) Loading XML bean definitions from class path resource [spring-config.xml]
12:52:50,345 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp--192.168.1.150-9080-3) Loading properties file from class path resource [spring.properties]
12:52:50,348 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp--192.168.1.150-9080-3) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6ddb6b07: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor]; root of factory hierarchy
12:52:50,366 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-3) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@2cc821ef
12:52:50,367 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-3) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@500b3f4c
12:52:50,368 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-3) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@26b58796
12:52:50,374 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp--192.168.1.150-9080-3) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
12:52:50,425 INFO  [org.hibernate.dialect.Dialect] (ajp--192.168.1.150-9080-3) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
12:52:50,428 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp--192.168.1.150-9080-3) HHH000397: Using ASTQueryTranslatorFactory
12:52:50,605 INFO  [stdout] (ajp--192.168.1.150-9080-3) UPDATE meh9qfr1uqch 5938
13:03:16,102 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE wegp27iyxw0j 2846
13:03:16,648 INFO  [stdout] (ajp--192.168.1.150-9080-4) INSERT 1xddpcvtis10e 5966
13:03:16,754 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT mhvagbqaxgsd 7337
13:03:16,792 INFO  [stdout] (ajp--192.168.1.150-9080-7) UPDATE 34fxu4haa4q5 9804
13:03:16,866 INFO  [stdout] (ajp--192.168.1.150-9080-3) UPDATE 5amkxlyuzyp8 8927
13:03:16,942 INFO  [stdout] (ajp--192.168.1.150-9080-3) UPDATE 11ykc13m0r10b 4393
13:03:17,611 INFO  [stdout] (ajp--192.168.1.150-9080-3) INSERT 1fkms210dthwr 488
13:03:18,198 INFO  [stdout] (ajp--192.168.1.150-9080-3) INSERT cfp1i5sy4bpt 3455
13:03:18,223 INFO  [stdout] (ajp--192.168.1.150-9080-7) UPDATE p9jqdlnpv5d8 1074
13:03:18,246 INFO  [stdout] (ajp--192.168.1.150-9080-4) INSERT fnu0r03mgas0 2027
13:03:18,263 INFO  [stdout] (ajp--192.168.1.150-9080-3) UPDATE dgh5ib56gze7 1215
13:03:18,296 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT 1n4x67w9aufr 7767
13:03:18,297 INFO  [stdout] (ajp--192.168.1.150-9080-9) UPDATE 8xy8prwm00yy 8807
13:03:18,326 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 1jkvwulhwqksx 6280
13:03:18,334 INFO  [stdout] (ajp--192.168.1.150-9080-8) INSERT 1lrmb4dyxurp2 5249
13:03:18,339 INFO  [stdout] (ajp--192.168.1.150-9080-3) UPDATE mo1vpdb5v0sm 5048
13:03:18,345 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE qb6e3wq3ok05 7163
13:03:18,357 INFO  [stdout] (ajp--192.168.1.150-9080-3) INSERT wlxcjpediiml 961
13:03:18,358 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT fr6ji76ohzsi 842
13:03:18,365 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT 1otburj6mb9er 7645
13:03:18,372 INFO  [stdout] (ajp--192.168.1.150-9080-9) INSERT 198eulbfrkd0b 6503
# LOGGING CLUSTER_SERVER2
13:03:16,786 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp--192.168.1.150-9081-2) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@652130d1: startup date [Tue Aug 14 13:03:16 CEST 2012]; root of context hierarchy
13:03:16,830 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp--192.168.1.150-9081-2) Loading XML bean definitions from class path resource [spring-config.xml]
13:03:17,107 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp--192.168.1.150-9081-2) Loading properties file from class path resource [spring.properties]
13:03:17,127 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp--192.168.1.150-9081-2) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5c594008: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor]; root of factory hierarchy
13:03:17,191 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9081-2) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@6ebfc8d0
13:03:17,192 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9081-2) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@3839029b
13:03:17,193 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9081-2) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@33ec79b6
13:03:17,286 INFO  [org.hibernate.annotations.common.Version] (ajp--192.168.1.150-9081-2) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
13:03:17,291 INFO  [org.hibernate.Version] (ajp--192.168.1.150-9081-2) HHH000412: Hibernate Core {4.0.1.Final}
13:03:17,293 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9081-2) HHH000206: hibernate.properties not found
13:03:17,295 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9081-2) HHH000021: Bytecode provider name : javassist
13:03:17,330 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp--192.168.1.150-9081-2) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
13:03:17,523 INFO  [org.hibernate.dialect.Dialect] (ajp--192.168.1.150-9081-2) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
13:03:17,543 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp--192.168.1.150-9081-2) HHH000397: Using ASTQueryTranslatorFactory
13:03:17,581 INFO  [org.hibernate.validator.util.Version] (ajp--192.168.1.150-9081-2) Hibernate Validator 4.2.0.Final
13:03:18,134 INFO  [stdout] (ajp--192.168.1.150-9081-4) INSERT 1fhk6fys4sd6j 9363
13:03:18,135 INFO  [stdout] (ajp--192.168.1.150-9081-8) INSERT re87jkorw73z 9832
13:03:18,141 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1ndgkrn77u2it 9820
13:03:18,142 INFO  [stdout] (ajp--192.168.1.150-9081-5) INSERT 1w2cp0u6lk89x 3356
13:03:18,143 INFO  [stdout] (ajp--192.168.1.150-9081-3) INSERT 17rjkpgd9eez9 5957
13:03:18,151 INFO  [stdout] (ajp--192.168.1.150-9081-9) UPDATE 1ke3x8flbzh2l 2468
13:03:18,152 INFO  [stdout] (ajp--192.168.1.150-9081-2) UPDATE b0hsnirgzegu 3428
13:03:18,208 INFO  [stdout] (ajp--192.168.1.150-9081-11) UPDATE 346ubsid1bcj 5107
13:03:18,217 INFO  [stdout] (ajp--192.168.1.150-9081-10) INSERT hhq72mspnlm6 3525
13:03:18,226 INFO  [stdout] (ajp--192.168.1.150-9081-3) INSERT 18z5vn487oq68 1145
13:03:18,229 INFO  [stdout] (ajp--192.168.1.150-9081-8) UPDATE 1g2v0qag7awbe 9292
13:03:18,241 INFO  [stdout] (ajp--192.168.1.150-9081-10) UPDATE 1iedrjwclb888 5015
13:03:18,244 INFO  [stdout] (ajp--192.168.1.150-9081-3) UPDATE h4nv7n4u4imi 431
13:03:18,256 INFO  [stdout] (ajp--192.168.1.150-9081-10) INSERT 146qoll1n1jpt 1994
13:03:18,265 INFO  [stdout] (ajp--192.168.1.150-9081-10) UPDATE sca0ze1e6a55 4618
13:03:18,273 INFO  [stdout] (ajp--192.168.1.150-9081-10) UPDATE neyi37tgskek 7683
13:03:18,331 INFO  [stdout] (ajp--192.168.1.150-9081-10) UPDATE 1itpm85ux9vu8 8101
13:03:18,344 INFO  [stdout] (ajp--192.168.1.150-9081-3) UPDATE 1hzxrlkqyxwvz 2642
13:03:18,350 INFO  [stdout] (ajp--192.168.1.150-9081-11) INSERT 1qsg68xingq39 5017
13:03:18,365 INFO  [stdout] (ajp--192.168.1.150-9081-8) INSERT 1a42lp62sxldw 6196
13:03:18,365 INFO  [stdout] (ajp--192.168.1.150-9081-10) UPDATE 1sd2tjmkikrwd 3633
13:03:18,368 INFO  [stdout] (ajp--192.168.1.150-9081-11) UPDATE 12326fhs1lgs6 1466
13:03:18,369 INFO  [stdout] (ajp--192.168.1.150-9081-3) INSERT 8z47zy6uo0lr 9042

JMS

Let us add some messaging as well. To this end, we add the following to the Spring configuration

<beans ...>
    <bean id="company" class="model.logic.CompanyBean">
        ...
        <property name="jmsTemplate" ref="jmstemplate"/>
    </bean>
	...
    <jee:jndi-lookup id="connectionfactory" jndi-name="java:/ConnectionFactory" resource-ref="false"/>
    <jee:jndi-lookup id="destination" jndi-name="java:/queue/test" resource-ref="false"/>
    <bean id="jmstemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="defaultDestination" ref="destination"/>
    </bean>
    <bean class="org.springframework.jms.listener.SimpleMessageListenerContainer">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="destination" ref="destination"/>
        <property name="messageListener" ref="companymdp"/>
    </bean>
    <bean id="companymdp" class="model.logic.CompanyMDP"/>
</beans>

To send messages we edit the CompanyBean class as follows, i.e., add a property called jmsTemplate, add a method sendMessage that is called from the insertPerson and removePerson methods

package model.logic;

import model.entities.Person;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.ObjectMessage;

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class CompanyBean implements Company {

    private SessionFactory sessionFactory;
	private JmsTemplate jmsTemplate;

    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    public JmsTemplate getJmsTemplate() {
        return jmsTemplate;
    }

    public void setJmsTemplate(JmsTemplate jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }

    public void insertPerson(Person person) {
        Person temporaryPerson = findPerson(person.getSofinummer());
        if (temporaryPerson == null) {
            System.out.println("INSERT " + person);
            getCurrentSession().save(person);
            sendMessage(person);
        } else {
            updatePerson(person);
        }
    }

    public void removePerson(Integer sofinummer) {
        Person temporaryPerson = findPerson(sofinummer);
        if (temporaryPerson != null) {
            System.out.println("REMOVE " + temporaryPerson);
            getCurrentSession().delete(temporaryPerson);
            sendMessage(temporaryPerson);
        }
    }

    public void updatePerson(Person person) {
        System.out.println("UPDATE " + person);
        getCurrentSession().merge(person);
    }

    private Person findPerson(Integer sofinummer) {
        return (Person) getCurrentSession().get(Person.class, sofinummer);
    }

    private final Session getCurrentSession() {
        return getSessionFactory().getCurrentSession();
    }

    private void sendMessage(final Person person) {
        getJmsTemplate().send(new MessageCreator(){
            public Message createMessage(javax.jms.Session session) throws JMSException {
                ObjectMessage message = session.createObjectMessage();
                message.setObject(person);
                return message;
            }
        });
    }
}

Before we can deploy the application, we have to make sure the javax.jms.api module is added to the org.springframework module, i.e.,

<module xmlns="urn:jboss:module:1.1" name="org.springframework">
    <resources>
	<resource-root path="aopalliance-1.0.jar"/>
	<resource-root path="cglib-2.2.2.jar"/>
	<resource-root path="commons-logging-1.0.4.jar"/>
	<resource-root path="org.springframework.aop-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.asm-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.beans-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.context-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.core-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.expression-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.jdbc-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.jms-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.orm-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.transaction-3.1.2.RELEASE.jar"/>
	<resource-root path="org.springframework.web-3.1.2.RELEASE.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api" export="true"/>
        <module name="org.apache.log4j" export="true"/>
        <module name="org.antlr" export="true"/>
        <module name="org.dom4j" export="true"/>
        <module name="org.hibernate" export="true"/>
        <module name="javax.persistence.api" export="true"/>
        <module name="org.javassist" export="true"/>
        <module name="org.jboss.logging" export="true"/>
        <module name="javax.transaction.api" export="true"/>
        <module name="javax.jms.api" export="true"/>
    </dependencies>
</module>

With the module in place, restart the servers and deploy the application, i.e.,

[domain@192.168.1.150:9999 /] undeploy SpringHibernate.war --server-groups=cluster-group
[domain@192.168.1.150:9999 /] /host=jboss/server-config=cluster-server2:restart
{
    "outcome" => "success",
    "result" => "STARTING"
}
[domain@192.168.1.150:9999 /] /host=jboss/server-config=cluster-server1:restart
{
    "outcome" => "success",
    "result" => "STARTING"
}
[domain@192.168.1.150:9999 /] deploy /home/jboss/jboss-as-7.1.0.Final/deploy/springhibernate/SpringHibernate.war --server-groups=cluster-group

The application can be reached at http://192.168.1.150:8888/SpringHibernate/testservlet. After doing a few requests the following is observed in the logging:

# LOGGING CLUSTER-SERVER1
15:45:13,723 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp--192.168.1.150-9080-5) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1b7fc253: startup date [Tue Aug 14 15:45:13 CEST 2012]; root of context hierarchy
15:45:13,760 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp--192.168.1.150-9080-5) Loading XML bean definitions from class path resource [spring-config.xml]
15:45:14,119 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp--192.168.1.150-9080-5) Loading properties file from class path resource [spring.properties]
15:45:14,141 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp--192.168.1.150-9080-5) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@411167f3: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.SimpleMessageListenerContainer#0,companymdp]; root of factory hierarchy
15:45:14,204 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-5) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@539546ee
15:45:14,204 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-5) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@3839029b
15:45:14,205 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-5) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@2818de48
15:45:14,291 INFO  [org.hibernate.annotations.common.Version] (ajp--192.168.1.150-9080-5) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
15:45:14,296 INFO  [org.hibernate.Version] (ajp--192.168.1.150-9080-5) HHH000412: Hibernate Core {4.0.1.Final}
15:45:14,297 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9080-5) HHH000206: hibernate.properties not found
15:45:14,299 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9080-5) HHH000021: Bytecode provider name : javassist
15:45:14,332 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp--192.168.1.150-9080-5) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
15:45:14,549 INFO  [org.hibernate.dialect.Dialect] (ajp--192.168.1.150-9080-5) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
15:45:14,567 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp--192.168.1.150-9080-5) HHH000397: Using ASTQueryTranslatorFactory
15:45:14,603 INFO  [org.hibernate.validator.util.Version] (ajp--192.168.1.150-9080-5) Hibernate Validator 4.2.0.Final
15:45:14,957 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (ajp--192.168.1.150-9080-5) Starting beans in phase 2147483647
15:45:15,124 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT fe1g8llttlid 9594
15:45:15,185 INFO  [stdout] (Thread-1 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE fe1g8llttlid 9594
15:47:17,962 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1ruzaxp3ovrza 5434
15:47:18,507 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 13uem5a3s0tr0 4176
15:47:18,555 INFO  [stdout] (Thread-2 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 13uem5a3s0tr0 4176
15:47:18,573 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT o0on52y2q6rc 7154
15:47:18,581 INFO  [stdout] (Thread-2 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE o0on52y2q6rc 7154
15:47:18,686 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE ji9vigyqm6tn 1580
15:47:18,721 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT 501w5lrllrl1 6984
15:47:18,734 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 501w5lrllrl1 6984
15:47:18,795 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT q8i3p3v69ta9 9696
15:47:18,808 INFO  [stdout] (Thread-1 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE q8i3p3v69ta9 9696
15:47:18,870 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 187qlr278gvk2 7989
15:47:18,944 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT af0n7nhmhtn4 7354
15:47:18,954 INFO  [stdout] (Thread-1 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE af0n7nhmhtn4 7354
15:47:19,773 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT 1rki73vjyxick 4429
15:47:19,797 INFO  [stdout] (Thread-2 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 1rki73vjyxick 4429
15:47:19,805 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT 7t977akfo2gv 6383
15:47:19,813 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 7t977akfo2gv 6383
15:47:20,265 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 18nupcmjbywyz 9416
15:47:20,272 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 18nupcmjbywyz 9416
15:47:20,288 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE ul6rda8yg61u 1891
15:47:20,298 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 1fotcalk9shsq 1717
15:47:20,306 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT fz2zkhr4bw9g 4969
15:47:20,330 INFO  [stdout] (Thread-2 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE fz2zkhr4bw9g 4969
15:47:20,332 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT nqmx27r3vcoz 7686
15:47:20,357 INFO  [stdout] (ajp--192.168.1.150-9080-4) INSERT 14znb00a9jipx 363
15:47:20,374 INFO  [stdout] (Thread-1 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE nqmx27r3vcoz 7686
15:47:20,389 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 14znb00a9jipx 363
15:47:20,426 INFO  [stdout] (ajp--192.168.1.150-9080-9) INSERT 8ptga7h7jpeb 6888
15:47:20,428 INFO  [stdout] (ajp--192.168.1.150-9080-7) UPDATE cuy0x72tv27s 4669
15:47:20,447 INFO  [stdout] (Thread-1 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 8ptga7h7jpeb 6888
15:47:20,465 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 3mws48gl5lz8 4333
15:47:20,467 INFO  [stdout] (ajp--192.168.1.150-9080-4) INSERT tfcnb3v0zt7p 7984
15:47:20,477 INFO  [stdout] (ajp--192.168.1.150-9080-8) INSERT 1ahyu3xkspnxr 3201
15:47:20,496 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 3mws48gl5lz8 4333
15:47:20,497 INFO  [stdout] (ajp--192.168.1.150-9080-6) UPDATE 137a6srifr1gz 8905
15:47:20,501 INFO  [stdout] (ajp--192.168.1.150-9080-10) UPDATE 16epgzgkpuhyl 3052
15:47:20,528 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE x59b33fx74ec 2535
15:47:20,528 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE 1ahyu3xkspnxr 3201
15:47:20,531 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT wkl0ag7vz56k 8274
15:47:20,537 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE tfcnb3v0zt7p 7984
15:47:20,543 INFO  [stdout] (Thread-4 (HornetQ-client-global-threads-1978193102)) RECEIVED OBJECT MESSAGE wkl0ag7vz56k 8274
# LOGGING CLUSTER-SERVER2
15:47:18,658 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@28b3cf4a: startup date [Tue Aug 14 15:47:18 CEST 2012]; root of context hierarchy
15:47:18,696 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Loading XML bean definitions from class path resource [spring-config.xml]
15:47:19,005 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Loading properties file from class path resource [spring.properties]
15:47:19,025 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3ff39e73: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.SimpleMessageListenerContainer#0,companymdp]; root of factory hierarchy
15:47:19,087 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@5935b50c
15:47:19,088 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@5b33a7af
15:47:19,090 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@54cf76c8
15:47:19,177 INFO  [org.hibernate.annotations.common.Version] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
15:47:19,182 INFO  [org.hibernate.Version] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HHH000412: Hibernate Core {4.0.1.Final}
15:47:19,184 INFO  [org.hibernate.cfg.Environment] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HHH000206: hibernate.properties not found
15:47:19,186 INFO  [org.hibernate.cfg.Environment] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HHH000021: Bytecode provider name : javassist
15:47:19,221 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
15:47:19,433 INFO  [org.hibernate.dialect.Dialect] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
15:47:19,454 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) HHH000397: Using ASTQueryTranslatorFactory
15:47:19,486 INFO  [org.hibernate.validator.util.Version] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Hibernate Validator 4.2.0.Final
15:47:19,893 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) Starting beans in phase 2147483647
15:47:20,126 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-5) INSERT 1uygcxcowtu9a 331
15:47:20,127 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-6) INSERT mow4srfubly0 6092
15:47:20,180 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-4) INSERT 45ctomltbfnj 7350
15:47:20,182 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-3) INSERT 2bfcfctogwas 9945
15:47:20,186 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-2) INSERT 1ghndct2k38fq 7215
15:47:20,190 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-8) UPDATE 1q6wykxdwe57w 8885
15:47:20,191 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-9) UPDATE edte8od9xrou 4704
15:47:20,192 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-10) UPDATE 1adm2wi7sosp0 3801
15:47:20,194 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-11) INSERT 1cof2wpo05qux 8205
15:47:20,195 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-7) INSERT 1jq47i7b26tvp 609
15:47:20,307 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-7) INSERT 1qxeatjtlqzx5 3722
15:47:20,313 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-12) UPDATE cztialmryr6t 2306
15:47:20,323 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 45ctomltbfnj 7350
15:47:20,335 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-3) UPDATE s964r48d3sen 6153
15:47:20,343 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-8) UPDATE g9jng4dhqtha 8360
15:47:20,359 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-12) INSERT 1fs7d2l62ags4 9334
15:47:20,363 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1ghndct2k38fq 7215
15:47:20,372 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-8) UPDATE 1fac6z0zdhxfo 4796
15:47:20,377 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1jq47i7b26tvp 609
15:47:20,378 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-5) UPDATE 1vkso90xvg1kf 3038
15:47:20,381 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-3) INSERT b5jtmtrok3ay 9950
15:47:20,385 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-12) INSERT 1eob8au4ivjaq 7646
15:47:20,394 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1uygcxcowtu9a 331
15:47:20,400 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-5) INSERT g3tpmc15n1pw 7940
15:47:20,403 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1cof2wpo05qux 8205
15:47:20,412 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE mow4srfubly0 6092
15:47:20,419 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 2bfcfctogwas 9945
15:47:20,421 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-5) INSERT ub7uqkgxgvkn 7389
15:47:20,423 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1qxeatjtlqzx5 3722
15:47:20,433 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1fs7d2l62ags4 9334
15:47:20,437 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-12) INSERT 1o9uvk6v2q3yh 6427
15:47:20,445 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE b5jtmtrok3ay 9950
15:47:20,454 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1eob8au4ivjaq 7646
15:47:20,459 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-5) UPDATE ztxczcv9lczr 6350
15:47:20,467 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE g3tpmc15n1pw 7940
15:47:20,472 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-3) INSERT 1e50cqtnnx877 4627
15:47:20,492 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9081-12) INSERT gzgnffn3j4jv 7794
15:47:20,495 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE ub7uqkgxgvkn 7389
15:47:20,507 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1o9uvk6v2q3yh 6427
15:47:20,511 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE 1e50cqtnnx877 4627
15:47:20,520 INFO  [stdout] (Thread-1 (HornetQ-client-global-threads-699447810)) RECEIVED OBJECT MESSAGE gzgnffn3j4jv 7794

Transactions

In the example above we have used a SimpleMessageListenerContainer. A message listener container is used to receive messages from a JMS message queue and drive the MessageListener that is injected into it. The listener container is responsible for all threading of message reception and dispatches into the listener for processing. A message listener container is the intermediary between an MDP and a messaging provider, and takes care of registering to receive messages, participating in transactions, resource acquisition and release, exception conversion and suchlike. There are two standard JMS message listener containers packaged with Spring, each with its specialised feature set:

  • SimpleMessageListenerContainer – This message listener container is the simpler of the two standard flavors. It creates a fixed number of JMS sessions and consumers at startup, registers the listener using the standard JMS MessageConsumer.setMessageListener method, and leaves it up the JMS provider to perform listener callbacks. This variant does not allow for dynamic adaption to runtime demands or for participation in externally managed transactions. Compatibility-wise, it stays very close to the spirit of the standalone JMS specification – but is generally not compatible with Java EE’s JMS restrictions.
  • DefaultMessageListenerContainer – This message listener container is the one used in most cases. In contrast to SimpleMessageListenerContainer, this container variant does allow for dynamic adaption to runtime demands and is able to participate in externally managed transactions. Each received message is registered with an XA transaction when configured with a JtaTransactionManager; so processing may take advantage of XA transaction semantics. This listener container strikes a good balance between low requirements on the JMS provider, advanced functionality such as transaction participation, and compatibility with Java EE environments.

To use the second flavor in our set-up, we can change the Spring configuration to

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
    <bean id="company" class="model.logic.CompanyBean">
        <property name="sessionFactory" ref="sessionfactory"/>
        <property name="jmsTemplate" ref="jmstemplate"/>
    </bean>
	<!-- Hibernate SessionFactory config -->
    <bean id="sessionfactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="datasource"/>
        <property name="jtaTransactionManager" ref="transactionManager"/>
        <property name="mappingResources">
            <list>
                <value>model/entities/person.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
                <prop key="hibernate.listeners.envers.autoRegister">${hibernate.listeners.envers.autoRegister}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            </props>
        </property>
    </bean>
	<!-- Transaction config -->
	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
	<tx:annotation-driven transaction-manager="transactionManager"/>
	<!-- Resource look-ups -->
    <jee:jndi-lookup id="datasource" jndi-name="java:/jdbc/OracleDS" resource-ref="false"/>
    <jee:jndi-lookup id="connectionfactory" jndi-name="java:/JmsXA" resource-ref="false"/>
    <jee:jndi-lookup id="destination" jndi-name="java:/queue/test" resource-ref="false"/>
    <!-- JMS config -->
	<bean id="jmstemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="defaultDestination" ref="destination"/>
    </bean>
    <bean class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="destination" ref="destination"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="messageListener" ref="companymdp"/>
    </bean>
    <bean id="companymdp" class="model.logic.CompanyMDP"/>
	<!-- Extra -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:spring.properties</value>
            </list>
        </property>
    </bean>
</beans>

Note that code remains as it was. We have used the following JBoss configuration that shows how the used resources are configured

<domain xmlns="urn:jboss:domain:1.1">
	...
    <profiles>
        <profile name="cluster">
            <subsystem xmlns="urn:jboss:domain:datasources:1.0">
                <datasources>
                    <datasource jta="true" jndi-name="java:/jdbc/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true" use-ccm="true">
                        <connection-url>jdbc:oracle:thin:@192.168.1.60:1521:orcl11</connection-url>
                        <driver>oracle</driver>
                        <pool>
                            <min-pool-size>1</min-pool-size>
                            <max-pool-size>15</max-pool-size>
                            <prefill>true</prefill>
                            <use-strict-min>true</use-strict-min>
                        </pool>
                        <security>
                            <user-name>example</user-name>
                            <password>example</password>
                        </security>
                        <timeout>
                            <idle-timeout-minutes>0</idle-timeout-minutes>
                            <query-timeout>600</query-timeout>
                        </timeout>
                        <statement>
                            <prepared-statement-cache-size>10</prepared-statement-cache-size>
                        </statement>
                    </datasource>
                    <drivers>
                        <driver name="oracle" module="com.oracle.database">
                            <driver-class>oracle.jdbc.OracleDriver</driver-class>
                            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                        </driver>
                    </drivers>
                </datasources>
            </subsystem>
            <subsystem xmlns="urn:jboss:domain:messaging:1.1">
                <hornetq-server>
					...
                    <jms-connection-factories>
						...
                        <pooled-connection-factory name="hornetq-ra">
                            <transaction mode="xa"/>
                            <connectors>
                                <connector-ref connector-name="in-vm"/>
                            </connectors>
                            <entries>
                                <entry name="java:/JmsXA"/>
                            </entries>
                        </pooled-connection-factory>
                    </jms-connection-factories>
                    <jms-destinations>
                        <jms-queue name="testQueue">
                            <entry name="java:/queue/test"/>
                            <entry name="java:jboss/exported/jms/queue/test"/>
                        </jms-queue>
						...
                    </jms-destinations>
                </hornetq-server>
            </subsystem>
			...
        </profile>
    </profiles>
	...
    <deployments>
        <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear">
            <content sha1="161f51dde7f085c822cc4c68b306d57f1bee902d"/>
        </deployment>
        <deployment name="SpringHibernate.war" runtime-name="SpringHibernate.war">
            <content sha1="574d0617d92d8439844633557937be754a134370"/>
        </deployment>
    </deployments>
    <server-groups>
		...
        <server-group name="cluster-group" profile="cluster">
            <jvm name="default"/>
            <socket-binding-group ref="cluster-sockets"/>
            <deployments>
                <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear"/>
                <deployment name="SpringHibernate.war" runtime-name="SpringHibernate.war" enabled="false"/>
            </deployments>
        </server-group>
    </server-groups>
</domain>

Note that we have set the mode of the connection factory to XA (as is required when using the JtaTransactionManager and the DefaultMessageListenerContainer). One important thing to remember when using the DefaultMessageListenerContainer is that the default sessionAcknowledgeMode setting is AUTO_ACKNOWLEDGE (see here), so it not smart to use message.acknowledge in the MDP, otherwise we will run into

09:33:20,815 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@74359b24: startup date [Fri Aug 17 09:33:20 CEST 2012]; root of context hierarchy
09:33:20,945 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Loading XML bean definitions from class path resource [spring-config.xml]
09:33:21,415 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Loading properties file from class path resource [spring.properties]
09:33:21,441 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6c11e58: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.DefaultMessageListenerContainer#0,companymdp]; root of factory hierarchy
09:33:21,535 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@7e0cf590
09:33:21,536 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@4d50b06b
09:33:21,537 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@38d060ac
09:33:21,784 INFO  [org.hibernate.annotations.common.Version] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
09:33:21,792 INFO  [org.hibernate.Version] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HHH000412: Hibernate Core {4.0.1.Final}
09:33:21,794 INFO  [org.hibernate.cfg.Environment] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HHH000206: hibernate.properties not found
09:33:21,796 INFO  [org.hibernate.cfg.Environment] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HHH000021: Bytecode provider name : javassist
09:33:21,907 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
09:33:22,517 INFO  [org.hibernate.dialect.Dialect] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
09:33:22,539 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) HHH000397: Using ASTQueryTranslatorFactory
09:33:22,652 INFO  [org.hibernate.validator.util.Version] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Hibernate Validator 4.2.0.Final
09:33:23,152 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) Starting beans in phase 2147483647
09:33:23,552 INFO  [stdout] (ajp-axis-into-ict.nl-192.168.1.150-9080-7) INSERT 1chrw6b78f2w9 9719
09:33:23,671 WARN  [org.springframework.jms.listener.DefaultMessageListenerContainer] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) Execution of JMS message listener failed, and no ErrorHandler has been set.: java.lang.RuntimeException: javax.jms.IllegalStateException: Non XA connection
    at model.logic.CompanyMDP.onMessage(CompanyMDP.java:16) [classes:]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:326) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:244) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1063) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:960) [org.springframework.jms-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
Caused by: javax.jms.IllegalStateException: Non XA connection
    at org.hornetq.ra.HornetQRASession.getSession(HornetQRASession.java:1246)
    at org.hornetq.ra.HornetQRAMessage.acknowledge(HornetQRAMessage.java:71)
    at model.logic.CompanyMDP.onMessage(CompanyMDP.java:13) [classes:]
    ... 9 more

Another thing worth mentioning is that within a JTA transaction, the parameters passed to create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method are not taken into account. Depending on the JavaEE transaction context, the container makes its own decisions on these values.

Let us deploy the application again and see what happens:

# LOGGING CLUSTER SERVER 1
14:03:01,180 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 32) JBAS015537: Activating WebServices Extension
14:03:01,242 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 36) JBAS013101: Activating Security Subsystem
14:03:01,245 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.6.final
14:03:01,359 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 42) JBAS011800: Activating Naming Subsystem
14:03:01,420 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 41) JBAS011940: Activating OSGi Subsystem
14:03:01,491 INFO  [org.jboss.as.naming] (MSC service thread 1-3) JBAS011802: Starting Naming Service
14:03:01,508 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:03:01,628 INFO  [org.jboss.as.clustering.jgroups] (ServerService Thread Pool -- 49) JBAS010260: Activating JGroups subsystem.
14:03:01,792 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 55) JBAS010280: Activating Infinispan subsystem.
14:03:01,813 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 54) JBAS016300: Activating JacORB Subsystem
14:03:01,883 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:03:01,894 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 59) JBAS016200: Activating ConfigAdmin Subsystem
14:03:01,913 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-3) JBoss Web Services - Stack CXF Server 4.0.1.GA
14:03:02,259 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
14:03:02,275 INFO  [org.jboss.as.modcluster] (MSC service thread 1-2) JBAS011704: Mod_cluster uses default load balancer provider
14:03:02,389 INFO  [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-3) Starting Coyote HTTP/1.1 on http--192.168.1.150-8080
14:03:02,413 INFO  [org.jboss.modcluster.ModClusterService] (MSC service thread 1-2) Initializing mod_cluster 1.2.0.Final
14:03:02,471 INFO  [org.apache.coyote.ajp.AjpAprProtocol] (MSC service thread 1-4) Starting Coyote AJP/1.3 on ajp--192.168.1.150-9080
14:03:02,515 INFO  [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
14:03:02,551 INFO  [org.jboss.modcluster.advertise.impl.AdvertiseListenerImpl] (MSC service thread 1-2) Listening to proxy advertisements on 224.0.1.105:23364
14:03:02,700 INFO  [org.jboss.as.jaxr] (MSC service thread 1-1) Binding JAXR ConnectionFactory: java:jboss/jaxr/ConnectionFactory
14:03:03,010 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server1/data/messagingjournal,bindingsDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server1/data/messagingbindings,largeMessagesDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server1/data/messaginglargemessages,pagingDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server1/data/messagingpaging)
14:03:03,012 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) Waiting to obtain live lock
14:03:03,064 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
14:03:03,244 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageManager] (MSC service thread 1-1) Using AIO Journal
14:03:03,256 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
14:03:03,673 INFO  [org.jboss.as.jacorb] (MSC service thread 1-3) JBAS016330: CORBA ORB Service started
14:03:03,741 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-1) Waiting to obtain live lock
14:03:03,742 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-1) Live Server Obtained live lock
14:03:04,099 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:03:04,107 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:/jdbc/OracleDS]
14:03:04,133 INFO  [org.jboss.as.jacorb] (MSC service thread 1-3) JBAS016328: CORBA Naming Service started
14:03:04,698 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on axis-into-ict.nl/192.168.1.150:4447
14:03:05,157 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-1) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5445 for CORE protocol
14:03:05,158 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-1) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5455 for CORE protocol
14:03:05,159 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) Server is now live
14:03:05,160 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [2e926cad-78e4-11e1-b1c7-000c2976c82d]) started
14:03:05,166 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.queue.testQueue
14:03:05,180 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
14:03:05,181 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/queue/test
14:03:05,210 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
14:03:05,211 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
14:03:05,212 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
14:03:05,213 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.topic.testTopic
14:03:05,278 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/topic/test
14:03:05,281 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test
14:03:05,288 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-3) JBAS010406: Registered connection factory java:/JmsXA
14:03:05,297 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-3) HornetQ resource adaptor started
14:03:05,298 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-3) IJ020002: Deployed: file://RaActivatorhornetq-ra
14:03:05,309 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-4) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
14:03:05,397 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 7781ms - Started 169 of 292 services (121 services are passive or on-demand)
14:03:11,925 INFO  [org.jboss.modcluster.ModClusterService] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Engine [jboss.web] will use jvmRoute: 2c78c6e8-7325-3857-8bfc-d957f56114dc
14:04:34,838 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "SpringHibernate.war"
14:04:35,410 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /SpringHibernate
14:04:35,621 INFO  [org.jboss.as.server] (host-controller-connection-threads - 1) JBAS018559: Deployed "SpringHibernate.war"
14:05:11,613 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp--192.168.1.150-9080-7) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4e24faf1: startup date [Wed Aug 22 14:05:11 CEST 2012]; root of context hierarchy
14:05:11,651 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp--192.168.1.150-9080-7) Loading XML bean definitions from class path resource [spring-config.xml]
14:05:11,912 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp--192.168.1.150-9080-7) Loading properties file from class path resource [spring.properties]
14:05:11,932 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp--192.168.1.150-9080-7) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@215a730d: defining beans [company,sessionfactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,datasource,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.DefaultMessageListenerContainer#0,companymdp,propertyConfigurer]; root of factory hierarchy
14:05:11,990 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-7) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@16360771
14:05:11,991 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-7) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@76efb90
14:05:11,992 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9080-7) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@500c8efc
14:05:12,080 INFO  [org.hibernate.annotations.common.Version] (ajp--192.168.1.150-9080-7) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
14:05:12,084 INFO  [org.hibernate.Version] (ajp--192.168.1.150-9080-7) HHH000412: Hibernate Core {4.0.1.Final}
14:05:12,086 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9080-7) HHH000206: hibernate.properties not found
14:05:12,088 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9080-7) HHH000021: Bytecode provider name : javassist
14:05:12,124 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp--192.168.1.150-9080-7) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
14:05:12,355 INFO  [org.hibernate.dialect.Dialect] (ajp--192.168.1.150-9080-7) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
14:05:12,376 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp--192.168.1.150-9080-7) HHH000397: Using ASTQueryTranslatorFactory
14:05:12,414 INFO  [org.hibernate.validator.util.Version] (ajp--192.168.1.150-9080-7) Hibernate Validator 4.2.0.Final
14:05:12,790 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (ajp--192.168.1.150-9080-7) Starting beans in phase 2147483647
14:05:12,921 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE tdq5p6nrua78 881
14:05:13,111 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT 3zbulkvppaht 1587
14:05:13,192 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 3zbulkvppaht 1587
14:05:19,838 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT 3677kx0gg6p8 3335
14:05:19,878 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 3677kx0gg6p8 3335
14:05:20,597 INFO  [stdout] (ajp--192.168.1.150-9080-7) UPDATE qd3nfb51iltt 5472
14:05:21,157 INFO  [stdout] (ajp--192.168.1.150-9080-7) INSERT 170gdo1t8e5ko 3391
14:05:21,225 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 170gdo1t8e5ko 3391
14:05:21,242 INFO  [stdout] (ajp--192.168.1.150-9080-6) INSERT 1vaezfdq5d887 5839
14:05:21,294 INFO  [stdout] (ajp--192.168.1.150-9080-3) UPDATE jlha13ox3hwq 4651
14:05:21,321 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1vaezfdq5d887 5839
14:05:21,368 INFO  [stdout] (ajp--192.168.1.150-9080-4) UPDATE s84z6ya9j2w5 65
14:05:21,443 INFO  [stdout] (ajp--192.168.1.150-9080-4) INSERT zsnamkv7f31q 4
14:05:21,505 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE zsnamkv7f31q 4
14:05:21,515 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT 1f7y1xru7z3ol 1814
14:05:21,530 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1f7y1xru7z3ol 1814
14:05:21,589 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 35fccgwsvlo0 2309
14:05:21,663 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT u0sdivuxanqf 1574
14:05:21,680 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE u0sdivuxanqf 1574
14:05:21,740 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE h93lz8lmamwm 7188
14:05:21,811 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT z03kievlq3ec 9039
14:05:21,866 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE z03kievlq3ec 9039
14:05:21,893 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1xfiowipw18ie 6334
14:05:21,960 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT t12jyo6mydxp 8628
14:05:21,995 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE t12jyo6mydxp 8628
14:05:22,035 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1b7mtaj9ux4cf 6651
14:05:22,070 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1b7mtaj9ux4cf 6651
14:05:22,109 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1497gjpwnx06e 5835
14:05:22,124 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1497gjpwnx06e 5835
14:05:22,182 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE jusago26clrr 470
14:05:22,257 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE cl3qbhtfb7ul 7990
14:05:22,330 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1nvbqqb80m410 2000
14:05:22,377 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1nvbqqb80m410 2000
14:05:22,405 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT hfpwva5k7dgp 6255
14:05:22,439 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE hfpwva5k7dgp 6255
14:05:22,479 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE awkvfp0doliq 6581
14:05:22,553 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1xbh2guvpaeal 2005
14:05:22,627 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT bq62t89yksnl 7832
14:05:22,645 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE bq62t89yksnl 7832
14:05:22,701 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1v9cegaooyl7l 8801
14:05:22,778 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 5afihmfmz78m 8493
14:05:22,817 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 5afihmfmz78m 8493
14:05:22,886 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1u06cy6ymizsc 8529
14:05:22,961 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE cnj2vloagv7n 105
14:05:23,034 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 7knlbcrs35tv 4975
14:05:23,070 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 7knlbcrs35tv 4975
14:05:23,109 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE icaxkpdgtqix 8605
14:05:23,183 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT ib776bswgvgs 1069
14:05:23,199 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE ib776bswgvgs 1069
14:05:23,258 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE pfbjj6qrx0lk 4247
14:05:23,337 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1flpyivctw575 7035
14:05:23,354 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1flpyivctw575 7035
14:05:23,408 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE hlot1fnb068s 1172
14:05:23,479 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT sz4k5gzq3jop 5815
14:05:23,495 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE sz4k5gzq3jop 5815
14:05:23,560 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT ay53hxwhydvt 1006
14:05:23,577 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE ay53hxwhydvt 1006
14:05:23,628 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE p8izdhg3kqwl 20
14:05:23,702 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1cbvcvwojd9r1 4816
14:05:23,776 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT bdeoggzsp10b 3061
14:05:23,834 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE bdeoggzsp10b 3061
14:05:23,851 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE tpkz5b3l2qxg 3116
14:05:23,925 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 9egiwbb1zqtk 9439
14:05:24,002 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE pebum5s3v56r 7314
14:05:24,072 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 5tvfzpub30ea 1084
14:05:24,091 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 5tvfzpub30ea 1084
14:05:24,147 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1pf8pteh26ykp 3161
14:05:24,225 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 3ze6zl91gz7b 916
14:05:24,276 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 3ze6zl91gz7b 916
14:05:24,295 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE zu9klw0bi6wd 1375
14:05:24,369 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1wf30ovze2jtf 1643
14:05:24,443 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 3evnoqlt6oag 4807
14:05:24,464 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 3evnoqlt6oag 4807
14:05:24,517 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT jixj7dxjn3bp 6387
14:05:24,532 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE jixj7dxjn3bp 6387
14:05:24,592 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT a01r5mb9ldf4 6501
14:05:24,620 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE a01r5mb9ldf4 6501
14:05:24,665 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 18w9pp8mdk461 2853
14:05:24,740 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE devujxahhtzj 4128
14:05:24,814 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1i88goa3n83oh 4485
14:05:24,837 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1i88goa3n83oh 4485
14:05:24,888 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 43shzvb5wlak 4168
14:05:24,963 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT t6gc6fxquz4m 1388
14:05:24,986 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE t6gc6fxquz4m 1388
14:05:25,036 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE qklpn5ve0ozp 2928
14:05:25,111 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 1nrm8lmgk26hp 7968
14:05:25,184 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE pdby3n7ae41s 8360
14:05:25,259 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT leqaa72xl4gm 810
14:05:25,274 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE leqaa72xl4gm 810
14:05:25,332 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1xyro8op0a0f3 4288
14:05:25,349 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1xyro8op0a0f3 4288
14:05:25,407 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1c12hea4x2acw 7731
14:05:25,451 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1c12hea4x2acw 7731
14:05:25,481 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT rzlgra4tco9e 8689
14:05:25,541 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE rzlgra4tco9e 8689
14:05:25,555 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1j7f10xaqfmv5 298
14:05:25,598 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1j7f10xaqfmv5 298
14:05:25,629 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1nah1yqhlz161 9179
14:05:25,662 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1nah1yqhlz161 9179
14:05:25,703 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE r8txbotr8vav 8849
14:05:25,778 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1g6cybvqakdi9 9726
14:05:25,818 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1g6cybvqakdi9 9726
14:05:25,852 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 14plps4rq06yt 7683
14:05:25,926 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 203bvunibuxk 8672
14:05:26,000 INFO  [stdout] (ajp--192.168.1.150-9080-5) REMOVE 1r9iozlb7qu9r 2409
14:05:26,018 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1r9iozlb7qu9r 2409
14:05:26,074 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1ppcfzih1b7n1 2650
14:05:26,089 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1ppcfzih1b7n1 2650
14:05:26,149 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1txlmv2g46ejn 7653
14:05:26,165 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1txlmv2g46ejn 7653
14:05:26,223 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE 14htpvro4ua8b 6724
14:05:26,297 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT gko8x4cupkow 2930
14:05:26,312 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE gko8x4cupkow 2930
14:05:26,370 INFO  [stdout] (ajp--192.168.1.150-9080-5) UPDATE v1umqwkx1k66 2260
14:05:26,445 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT zgqo2m35w2rf 1036
14:05:26,462 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE zgqo2m35w2rf 1036
14:05:26,519 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 13wg0dr2yz95m 5299
14:05:26,573 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 13wg0dr2yz95m 5299
14:05:26,601 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT m0u74puq89vw 9140
14:05:26,668 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 1o73cgsnhxe1l 7199
14:05:26,690 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE m0u74puq89vw 9140
14:05:26,742 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE g3gvziu30w7f 2402
14:05:26,815 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE zjf2pdu9snm1 1587
14:05:26,889 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 615ovr9vnkzc 2066
14:05:26,964 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT jpwd49sr1cly 5427
14:05:26,992 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE jpwd49sr1cly 5427
14:05:27,038 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT 1s0qu81j9u4q 2307
14:05:27,057 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1s0qu81j9u4q 2307
14:05:27,111 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT 1s0apr8p9juh4 1542
14:05:27,146 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1s0apr8p9juh4 1542
14:05:27,186 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE gjs31ymrin87 4821
14:05:27,260 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 11vot9hvntfs8 35
14:05:27,334 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 1xo7mg9v65stg 1049
14:05:27,408 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT wktkiqe9pqns 4409
14:05:27,424 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE wktkiqe9pqns 4409
14:05:27,482 INFO  [stdout] (ajp--192.168.1.150-9080-2) INSERT tm5zdpk92har 7091
14:05:27,556 INFO  [stdout] (ajp--192.168.1.150-9080-5) INSERT 1bc5firf5fmpp 4603
14:05:27,581 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE tm5zdpk92har 7091
14:05:27,673 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 7wamgve30owb 4823
14:05:27,678 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1bc5firf5fmpp 4603
14:05:27,705 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE gdphs99168dv 3373
14:05:27,780 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE 1g9af1sb4cg8a 8509
14:05:27,853 INFO  [stdout] (ajp--192.168.1.150-9080-2) UPDATE nz1m577xzqs0 9061
# LOGGING CLUSTER SERVER 2
14:03:01,204 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 32) JBAS015537: Activating WebServices Extension
14:03:01,288 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 36) JBAS013101: Activating Security Subsystem
14:03:01,312 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.6.final
14:03:01,367 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 41) JBAS011940: Activating OSGi Subsystem
14:03:01,398 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 42) JBAS011800: Activating Naming Subsystem
14:03:01,538 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service
14:03:01,575 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:03:01,635 INFO  [org.jboss.as.clustering.jgroups] (ServerService Thread Pool -- 49) JBAS010260: Activating JGroups subsystem.
14:03:01,706 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 54) JBAS016300: Activating JacORB Subsystem
14:03:01,716 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 55) JBAS010280: Activating Infinispan subsystem.
14:03:01,809 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:03:01,819 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 59) JBAS016200: Activating ConfigAdmin Subsystem
14:03:01,832 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.1.GA
14:03:02,005 INFO  [org.jboss.as.connector] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
14:03:02,190 INFO  [org.jboss.as.modcluster] (MSC service thread 1-2) JBAS011704: Mod_cluster uses default load balancer provider
14:03:02,253 INFO  [org.jboss.as.jaxr] (MSC service thread 1-1) Binding JAXR ConnectionFactory: java:jboss/jaxr/ConnectionFactory
14:03:02,340 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
14:03:02,366 INFO  [org.jboss.modcluster.ModClusterService] (MSC service thread 1-2) Initializing mod_cluster 1.2.0.Final
14:03:02,417 INFO  [org.apache.coyote.ajp.AjpAprProtocol] (MSC service thread 1-4) Starting Coyote AJP/1.3 on ajp-axis-into-ict.nl-192.168.1.150-9081
14:03:02,475 INFO  [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-3) Starting Coyote HTTP/1.1 on http-axis-into-ict.nl-192.168.1.150-8081
14:03:02,479 INFO  [org.jboss.modcluster.advertise.impl.AdvertiseListenerImpl] (MSC service thread 1-2) Listening to proxy advertisements on 224.0.1.105:23364
14:03:02,647 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server2/data/messagingjournal,bindingsDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server2/data/messagingbindings,largeMessagesDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server2/data/messaginglargemessages,pagingDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/cluster-server2/data/messagingpaging)
14:03:02,651 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) Waiting to obtain live lock
14:03:02,858 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
14:03:02,885 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageManager] (MSC service thread 1-1) Using AIO Journal
14:03:03,042 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
14:03:03,486 INFO  [org.jboss.as.jacorb] (MSC service thread 1-3) JBAS016330: CORBA ORB Service started
14:03:03,584 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-1) Waiting to obtain live lock
14:03:03,586 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-1) Live Server Obtained live lock
14:03:03,859 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:03:03,943 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:/jdbc/OracleDS]
14:03:04,191 INFO  [org.jboss.as.jacorb] (MSC service thread 1-3) JBAS016328: CORBA Naming Service started
14:03:04,825 INFO  [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on axis-into-ict.nl/192.168.1.150:4448
14:03:05,139 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-1) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5446 for CORE protocol
14:03:05,141 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-1) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5456 for CORE protocol
14:03:05,142 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) Server is now live
14:03:05,143 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [3f00f7a1-78e4-11e1-800d-000c2976c82d]) started
14:03:05,163 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
14:03:05,165 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.topic.testTopic
14:03:05,203 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/topic/test
14:03:05,210 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test
14:03:05,211 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
14:03:05,212 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
14:03:05,214 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) trying to deploy queue jms.queue.testQueue
14:03:05,224 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
14:03:05,232 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/queue/test
14:03:05,261 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-1) JBAS010406: Registered connection factory java:/JmsXA
14:03:05,270 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-1) HornetQ resource adaptor started
14:03:05,271 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-1) IJ020002: Deployed: file://RaActivatorhornetq-ra
14:03:05,274 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
14:03:05,359 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 7666ms - Started 169 of 292 services (121 services are passive or on-demand)
14:03:11,983 INFO  [org.jboss.modcluster.ModClusterService] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Engine [jboss.web] will use jvmRoute: 4d87f106-10ff-342f-a6e6-eb2377d7c23f
14:04:34,835 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "SpringHibernate.war"
14:04:35,550 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /SpringHibernate
14:04:35,621 INFO  [org.jboss.as.server] (host-controller-connection-threads - 2) JBAS018559: Deployed "SpringHibernate.war"
14:05:16,923 INFO  [org.springframework.context.support.ClassPathXmlApplicationContext] (ajp--192.168.1.150-9081-8) Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@a58d300: startup date [Wed Aug 22 14:05:16 CEST 2012]; root of context hierarchy
14:05:16,960 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ajp--192.168.1.150-9081-8) Loading XML bean definitions from class path resource [spring-config.xml]
14:05:17,216 INFO  [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] (ajp--192.168.1.150-9081-8) Loading properties file from class path resource [spring.properties]
14:05:17,234 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ajp--192.168.1.150-9081-8) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@164163e1: defining beans [company,sessionfactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,datasource,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.DefaultMessageListenerContainer#0,companymdp,propertyConfigurer]; root of factory hierarchy
14:05:17,301 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9081-8) Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@575887db
14:05:17,302 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9081-8) Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@445aa997
14:05:17,303 INFO  [org.springframework.transaction.jta.JtaTransactionManager] (ajp--192.168.1.150-9081-8) Using JTA TransactionSynchronizationRegistry: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@1b1dd242
14:05:17,389 INFO  [org.hibernate.annotations.common.Version] (ajp--192.168.1.150-9081-8) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
14:05:17,394 INFO  [org.hibernate.Version] (ajp--192.168.1.150-9081-8) HHH000412: Hibernate Core {4.0.1.Final}
14:05:17,395 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9081-8) HHH000206: hibernate.properties not found
14:05:17,397 INFO  [org.hibernate.cfg.Environment] (ajp--192.168.1.150-9081-8) HHH000021: Bytecode provider name : javassist
14:05:17,435 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (ajp--192.168.1.150-9081-8) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
14:05:17,659 INFO  [org.hibernate.dialect.Dialect] (ajp--192.168.1.150-9081-8) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
14:05:17,678 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ajp--192.168.1.150-9081-8) HHH000397: Using ASTQueryTranslatorFactory
14:05:17,711 INFO  [org.hibernate.validator.util.Version] (ajp--192.168.1.150-9081-8) Hibernate Validator 4.2.0.Final
14:05:17,993 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (ajp--192.168.1.150-9081-8) Starting beans in phase 2147483647
14:05:18,212 INFO  [stdout] (ajp--192.168.1.150-9081-8) UPDATE 1nuxg993ownem 3052
14:05:21,115 INFO  [stdout] (ajp--192.168.1.150-9081-8) UPDATE afhvji2k8ft7 2716
14:05:21,185 INFO  [stdout] (ajp--192.168.1.150-9081-5) INSERT 1ihgf2p7aavvv 6429
14:05:21,328 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1ihgf2p7aavvv 6429
14:05:21,329 INFO  [stdout] (ajp--192.168.1.150-9081-3) UPDATE 1om511m6nzi22 4774
14:05:21,343 INFO  [stdout] (ajp--192.168.1.150-9081-4) INSERT 1hwkf2797ujf6 5149
14:05:21,404 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1hwkf2797ujf6 5149
14:05:21,441 INFO  [stdout] (ajp--192.168.1.150-9081-6) INSERT 1ezyhvfha3q2t 3836
14:05:21,478 INFO  [stdout] (ajp--192.168.1.150-9081-4) UPDATE 1ixbel89n7f5w 9298
14:05:21,502 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1ezyhvfha3q2t 3836
14:05:21,551 INFO  [stdout] (ajp--192.168.1.150-9081-6) INSERT 1us8n7k0bnqpo 5426
14:05:21,593 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1us8n7k0bnqpo 5426
14:05:21,627 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1ppw7krne465v 6792
14:05:21,701 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1prt2df94i5mk 2092
14:05:21,776 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 10gvhg82ztew9 2783
14:05:21,793 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 10gvhg82ztew9 2783
14:05:21,858 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1bd9yo40vzizt 1911
14:05:21,923 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 5n9h8rwq7q60 1343
14:05:21,997 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 8m9k1pr28gg 5547
14:05:22,013 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 8m9k1pr28gg 5547
14:05:22,071 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 17r9ee4bt0yxs 3649
14:05:22,150 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1gn2tjij0f1ob 1035
14:05:22,219 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT m6xox6axoz3b 3157
14:05:22,235 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE m6xox6axoz3b 3157
14:05:22,294 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 110r9484rvt73 294
14:05:22,310 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 110r9484rvt73 294
14:05:22,368 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1c9c6tb2agswh 9932
14:05:22,407 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1c9c6tb2agswh 9932
14:05:22,444 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 50ipwt1zajdx 2131
14:05:22,515 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 29h8tcc65j3 4548
14:05:22,533 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 29h8tcc65j3 4548
14:05:22,594 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT bhunhawsm27p 1700
14:05:22,611 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE bhunhawsm27p 1700
14:05:22,664 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 9bh7fa74xnrm 1225
14:05:22,738 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 19f4hj421s3fe 5128
14:05:22,815 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT ydgfqj2u2aax 8844
14:05:22,833 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE ydgfqj2u2aax 8844
14:05:22,849 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT mmw7kqjojuyq 1966
14:05:22,865 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE mmw7kqjojuyq 1966
14:05:22,923 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE qpbhdyvgftko 9965
14:05:22,997 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT m22f1xogzs2w 5940
14:05:23,013 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE m22f1xogzs2w 5940
14:05:23,075 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE q9lquj1fxj4m 4504
14:05:23,147 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE belkm98whjwh 7385
14:05:23,222 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1dq640hgxrqoe 496
14:05:23,239 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1dq640hgxrqoe 496
14:05:23,294 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1pevcvw6wa91q 8567
14:05:23,323 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1pevcvw6wa91q 8567
14:05:23,370 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 15bm9suyux8ui 1530
14:05:23,389 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 15bm9suyux8ui 1530
14:05:23,443 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1kmqno89copfp 7009
14:05:23,516 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1l8beowesem93 8780
14:05:23,547 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1l8beowesem93 8780
14:05:23,595 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1k9yrkaxqeizz 7066
14:05:23,665 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE p93n8ojg5gaf 8632
14:05:23,739 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1v9ix94fvw3s2 5428
14:05:23,813 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT eo8kvhum40m3 4855
14:05:23,849 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE eo8kvhum40m3 4855
14:05:23,887 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT ehuvh8mnrdor 7519
14:05:23,901 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE ehuvh8mnrdor 7519
14:05:23,962 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 42395k914sap 9967
14:05:23,988 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 42395k914sap 9967
14:05:24,035 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT y3s6i0iy5bxc 2600
14:05:24,051 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE y3s6i0iy5bxc 2600
14:05:24,111 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 3us32d2krjvq 4008
14:05:24,186 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 9rg1q23jbt1h 5890
14:05:24,208 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 9rg1q23jbt1h 5890
14:05:24,332 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1ayxc04tdei19 9978
14:05:24,348 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1ayxc04tdei19 9978
14:05:24,406 INFO  [stdout] (ajp--192.168.1.150-9081-7) REMOVE 1aczxa7rq66gc 7734
14:05:24,422 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1aczxa7rq66gc 7734
14:05:24,480 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1qxbi4c03ptl3 2096
14:05:24,494 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1qxbi4c03ptl3 2096
14:05:24,554 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE k2zwhkup05z6 8428
14:05:24,633 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT as7552dnufu 899
14:05:24,648 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE as7552dnufu 899
14:05:24,703 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT l5zi29x6gxno 5344
14:05:24,717 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE l5zi29x6gxno 5344
14:05:24,777 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE r311dyu91dym 1859
14:05:24,852 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1fxxn3gl91h8m 3280
14:05:24,925 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1xqnw0zd807wd 2425
14:05:24,975 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1xqnw0zd807wd 2425
14:05:25,001 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1md19po93vtqw 6630
14:05:25,073 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 2c9cplr913cz 1431
14:05:25,108 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 2c9cplr913cz 1431
14:05:25,147 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT v43yhet3xd1g 66
14:05:25,162 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE v43yhet3xd1g 66
14:05:25,221 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1f7m1o552i1ap 5103
14:05:25,296 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1vso63da2hxsz 4821
14:05:25,369 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT sz5f4p22ihxm 8460
14:05:25,418 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE sz5f4p22ihxm 8460
14:05:25,445 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 2a7fe1kbyn05 3485
14:05:25,496 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 2a7fe1kbyn05 3485
14:05:25,518 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT ydkzaajaai23 8793
14:05:25,585 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE ydkzaajaai23 8793
14:05:25,593 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1nazvx44fsryy 2224
14:05:25,610 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1nazvx44fsryy 2224
14:05:25,667 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT ckpdo13cbu3v 8647
14:05:25,681 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE ckpdo13cbu3v 8647
14:05:25,740 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT bnydn2bxk8wd 1831
14:05:25,755 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE bnydn2bxk8wd 1831
14:05:25,815 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE fl1lk4bscdoj 7360
14:05:25,889 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE r8s5rxlisovh 3498
14:05:25,963 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1o12rg3cdx2vk 1350
14:05:26,037 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1gr04agkc8l6 4563
14:05:26,111 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1c3ksedbtpaoq 3054
14:05:26,150 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1c3ksedbtpaoq 3054
14:05:26,185 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 17s438pq34yde 3952
14:05:26,219 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 17s438pq34yde 3952
14:05:26,259 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 14grcfgntxm7g 6624
14:05:26,274 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 14grcfgntxm7g 6624
14:05:26,333 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 9rlyy5ku91wv 257
14:05:26,348 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 9rlyy5ku91wv 257
14:05:26,407 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 5ek3d1123mwp 3383
14:05:26,451 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 5ek3d1123mwp 3383
14:05:26,481 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT xucmrjfo2tkr 3652
14:05:26,526 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE xucmrjfo2tkr 3652
14:05:26,556 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 13st8rbs16ek0 4776
14:05:26,586 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 13st8rbs16ek0 4776
14:05:26,631 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 21xvhp0ohbc0 6680
14:05:26,705 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT yyqn8d3edsvp 340
14:05:26,751 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE yyqn8d3edsvp 340
14:05:26,779 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 19qwovr0pstvu 3878
14:05:26,852 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 10lz3rhlhi1mn 8828
14:05:26,926 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 5m3i1gvcm0jx 4490
14:05:26,971 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 5m3i1gvcm0jx 4490
14:05:27,007 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 10x2dlavqagr7 1772
14:05:27,053 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 10x2dlavqagr7 1772
14:05:27,074 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1irlznr87cp7v 6876
14:05:27,149 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT jh9pj68vmhla 7165
14:05:27,196 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE jh9pj68vmhla 7165
14:05:27,222 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 2eibuwgmnyai 1734
14:05:27,297 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE cmh5uq6jfdh1 1425
14:05:27,371 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1by141cbe2jw2 3937
14:05:27,415 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1by141cbe2jw2 3937
14:05:27,446 INFO  [stdout] (ajp--192.168.1.150-9081-7) INSERT 1t1gansg3mryj 540
14:05:27,520 INFO  [stdout] (ajp--192.168.1.150-9081-6) INSERT b8uhwlgalst0 7532
14:05:27,544 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE b8uhwlgalst0 7532
14:05:27,584 INFO  [stdout] (org.springframework.jms.listener.DefaultMessageListenerContainer#0-1) RECEIVED OBJECT MESSAGE 1t1gansg3mryj 540
14:05:27,594 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1ox069v1p4zue 7684
14:05:27,686 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 12obz6cvdizpk 4250
14:05:27,741 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE z7hc2gm1tko7 9967
14:05:27,819 INFO  [stdout] (ajp--192.168.1.150-9081-7) UPDATE 1sn0ranavpi7w 4442

Migration

Let us just deploy the application on WebLogic Server and see if we can get the Spring Hibernate application to work here as well. To this end, we create two shared libraries one for Spring 3.1.2 and one for Hibernate 4.1.2. The hibernate-4.1.war shared library has the following contents:

hibernate-4.1
	META-INF
		MANIFEST.MF
	WEB-INF
		lib
			antlr-2.7.7.jar
			dom4j-1.6.1.jar
			hibernate-commons-annotations-4.0.1.Final.jar
			hibernate-core-4.1.2.Final.jar
			hibernate-jpa-2.0-api-1.0.1.Final.jar
			javassist-3.15.0-GA.jar
			jboss-logging-3.1.0.GA.jar
			jboss-transaction-api_1.1_spec-1.0.0.Final.jar

in which the MANIFEST.MF contains:

Manifest-Version: 1.0
Created-By: 1.6.0_05 (BEA Systems, Inc.)
Extension-Name: hibernate
Specification-Title: Hibernate Library
Specification-Version: 4.1
Specification-Vendor: Middleware Magic
Implementation-Title: Hibernate Library
Implementation-Version: 4.1.2
Implementation-Vendor: Middleware Magic

The spring-3.1.war shared library has the following contents:

spring-3.1
	META-INF
		MANIFEST.MF
	WEB-INF
		lib
			aopalliance-1.0.jar
			cglib-2.2.2.jar
			commons-logging-1.0.4.jar
			org.springframework.aop-3.1.2.RELEASE.jar
			org.springframework.asm-3.1.2.RELEASE.jar
			org.springframework.beans-3.1.2.RELEASE.jar
			org.springframework.context-3.1.2.RELEASE.jar
			org.springframework.core-3.1.2.RELEASE.jar
			org.springframework.expression-3.1.2.RELEASE.jar
			org.springframework.jdbc-3.1.2.RELEASE.jar
			org.springframework.jms-3.1.2.RELEASE.jar
			org.springframework.orm-3.1.2.RELEASE.jar
			org.springframework.transaction-3.1.2.RELEASE.jar
			org.springframework.web-3.1.2.RELEASE.jar

in which the MANIFEST.MF contains:

Manifest-Version: 1.0
Created-By: 1.6.0_05 (BEA Systems, Inc.)
Extension-Name: spring
Specification-Title: Spring Library
Specification-Version: 3.1
Specification-Vendor: Middleware Magic
Implementation-Title: Spring Library
Implementation-Version: 3.1.2
Implementation-Vendor: Middleware Magic

We deploy the shared libraries to the WebLogic environment that is set-up as in the post Deploy WebLogic12c to Multiple Machines. The used Spring configuration looks as follows:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
    <bean id="company" class="model.logic.CompanyBean">
        <property name="sessionFactory" ref="sessionfactory"/>
        <property name="jmsTemplate" ref="jmstemplate"/>
    </bean>
	<!-- Hibernate SessionFactory config -->
    <bean id="sessionfactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="datasource"/>
        <property name="jtaTransactionManager" ref="transactionManager"/>
        <property name="mappingResources">
            <list>
                <value>model/entities/person.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
                <prop key="hibernate.listeners.envers.autoRegister">${hibernate.listeners.envers.autoRegister}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            </props>
        </property>
    </bean>
	<!-- Transaction config -->
	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
	<tx:annotation-driven transaction-manager="transactionManager"/>
	<!-- Resource look-ups -->
    <jee:jndi-lookup id="datasource" jndi-name="jdbc/exampleDS" resource-ref="false"/>
    <jee:jndi-lookup id="connectionfactory" jndi-name="jms/ConnectionFactory" resource-ref="false"/>
	<jee:jndi-lookup id="destination" jndi-name="jms/CompanyQueue" resource-ref="false"/>
    <!-- JMS config -->
	<bean id="jmstemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="defaultDestination" ref="destination"/>
    </bean>
    <bean class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="destination" ref="destination"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="messageListener" ref="companymdp"/>
    </bean>
    <bean id="companymdp" class="model.logic.CompanyMDP"/>
	<!-- Extra -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:spring.properties</value>
            </list>
        </property>
    </bean>
</beans>

Note that the only things that are changed are the JNDI-names of the used resources (data source, connection factory and destination). In order to deploy the application to WebLogic we can use the following directory structure

/springhibernate
	/app
		SpringHibernate.war
	/plan
		/WEB-INF
			weblogic.xml
		plan.xml

in which weblogic.xml has the following contents

<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
	<container-descriptor>
		<prefer-application-packages>
			<package-name>antlr.*</package-name>
		</prefer-application-packages>
	</container-descriptor>
	<library-ref>
		<library-name>hibernate</library-name>
		<specification-version>4.1</specification-version>
		<implementation-version>4.1.2</implementation-version>
		<exact-match>true</exact-match>
	</library-ref>
	<library-ref>
		<library-name>spring</library-name>
		<specification-version>3.1</specification-version>
		<implementation-version>3.1.2</implementation-version>
		<exact-match>true</exact-match>
	</library-ref>
</weblogic-web-app>

When the application is deployed and the testservlet is accessed the following is observed in the logging

# LOGGING CLUSTER-SERVER1
Aug 17, 2012 11:17:18 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1e3741a5: startup date [Fri Aug 17 11:17:18 CEST 2012]; root of context hierarchy
Aug 17, 2012 11:17:18 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config.xml]
Aug 17, 2012 11:17:18 AM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [spring.properties]
Aug 17, 2012 11:17:18 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1e57db48: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.DefaultMessageListenerContainer#0,companymdp]; root of factory hierarchy
Aug 17, 2012 11:17:18 AM org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager
INFO: Using JTA UserTransaction: ClientTM[cluster-server1+axis-into-ict.nl:9001+base_domain+t3+]
Aug 17, 2012 11:17:18 AM org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager
INFO: Using JTA TransactionManager: ClientTM[cluster-server1+axis-into-ict.nl:9001+base_domain+t3+]
Aug 17, 2012 11:17:18 AM org.springframework.transaction.jta.JtaTransactionManager initTransactionSynchronizationRegistry
INFO: Using JTA TransactionSynchronizationRegistry: ClientTM[cluster-server1+axis-into-ict.nl:9001+base_domain+t3+]
Aug 17, 2012 11:17:19 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Aug 17, 2012 11:17:19 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.2.Final}
Aug 17, 2012 11:17:19 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 17, 2012 11:17:19 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 17, 2012 11:17:19 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Aug 17, 2012 11:17:19 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
Aug 17, 2012 11:17:19 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Aug 17, 2012 11:17:20 AM org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup start
INFO: Starting beans in phase 2147483647
INSERT 1vfaxqqm2868k 9170
RECEIVED OBJECT MESSAGE 1vfaxqqm2868k 9170
INSERT 1azwiw7lwh4y7 6205
RECEIVED OBJECT MESSAGE 1azwiw7lwh4y7 6205
UPDATE 1t4a3l9tlt0i1 7843
UPDATE 1gpie3s1fmk7a 5058
UPDATE wgiimvyfwc8i 5756
INSERT 1tmgsmdsi2sbh 435
RECEIVED OBJECT MESSAGE 1tmgsmdsi2sbh 435
UPDATE 1mqtq9gwil0py 8978
INSERT ts5nfho8b4wb 3167
RECEIVED OBJECT MESSAGE ts5nfho8b4wb 3167
INSERT j878nzzqf3b3 3553
RECEIVED OBJECT MESSAGE j878nzzqf3b3 3553
INSERT 1upuhpirvr0a7 938
RECEIVED OBJECT MESSAGE 1upuhpirvr0a7 938
UPDATE mgt58gj3d61n 3538
INSERT 1q5smfr3dh6df 2715
RECEIVED OBJECT MESSAGE 1q5smfr3dh6df 2715
UPDATE 1r3jwyj2g5x5m 6113
UPDATE 1d6cpm9lavqwg 1972
INSERT vxc1h63kfy2w 1496
RECEIVED OBJECT MESSAGE vxc1h63kfy2w 1496
INSERT 55otw4aj7n7u 3826
RECEIVED OBJECT MESSAGE 55otw4aj7n7u 3826
INSERT 1dl36wovta1vf 8045
RECEIVED OBJECT MESSAGE 1dl36wovta1vf 8045
INSERT p1693zg2q0bl 4673
RECEIVED OBJECT MESSAGE p1693zg2q0bl 4673
INSERT 1e6c1ssik0esu 8536
RECEIVED OBJECT MESSAGE 1e6c1ssik0esu 8536
INSERT w7hlqytbosrt 2874
RECEIVED OBJECT MESSAGE w7hlqytbosrt 2874
UPDATE 152p5lvqwxco8 9516
INSERT byh8hu448t7w 8913
RECEIVED OBJECT MESSAGE byh8hu448t7w 8913
INSERT 1dajek4kv7xgb 8368
RECEIVED OBJECT MESSAGE 1dajek4kv7xgb 8368
INSERT ju0rs6v1k0dv 6421
RECEIVED OBJECT MESSAGE ju0rs6v1k0dv 6421
UPDATE 107qwp5m3bh6u 4167
INSERT uewom3s9awr0 4933
RECEIVED OBJECT MESSAGE uewom3s9awr0 4933
INSERT 1gejfty8uqly1 9279
RECEIVED OBJECT MESSAGE 1gejfty8uqly1 9279
INSERT ixpxzvpr08ww 5428
RECEIVED OBJECT MESSAGE ixpxzvpr08ww 5428
INSERT 17qi3yaxwtrxu 7411
RECEIVED OBJECT MESSAGE 17qi3yaxwtrxu 7411
UPDATE 7fgzuwkcz48e 5716
INSERT 1tbtnsilprbmm 8680
RECEIVED OBJECT MESSAGE 1tbtnsilprbmm 8680
UPDATE 1b2b771wi8waz 6832
INSERT 14v47vzyr5egt 564
RECEIVED OBJECT MESSAGE 14v47vzyr5egt 564
INSERT v30iv4nv8g5n 4052
RECEIVED OBJECT MESSAGE v30iv4nv8g5n 4052
UPDATE 1f2rqzn03y5qq 7750
REMOVE 1ibtlrunczhdk 4166
REMOVE 19fzxc64sngs1 5131
INSERT 981c8ahs90go 6356
RECEIVED OBJECT MESSAGE 1ibtlrunczhdk 4166
RECEIVED OBJECT MESSAGE 981c8ahs90go 6356
RECEIVED OBJECT MESSAGE 19fzxc64sngs1 5131
INSERT 1dm92l3kuloyc 3669
RECEIVED OBJECT MESSAGE 1dm92l3kuloyc 3669
UPDATE 3dtym6dsmm8j 6477
UPDATE jm5v2s8kq5cn 436
UPDATE 1aa1z7okdo09k 8246
INSERT jjnultqc90f4 9607
RECEIVED OBJECT MESSAGE jjnultqc90f4 9607
INSERT 1mmixox5tpnnn 3279
RECEIVED OBJECT MESSAGE 1mmixox5tpnnn 3279
INSERT 1227bi0v86b3t 4022
RECEIVED OBJECT MESSAGE 1227bi0v86b3t 4022
UPDATE stvbc1ya5lc2 8047
UPDATE 1xntj3pwd7p9x 258
UPDATE 1k6r3ryeo8ulm 6901
UPDATE b2e526chsv6o 2934
INSERT 1q0axu96bm6lg 7173
RECEIVED OBJECT MESSAGE 1q0axu96bm6lg 7173
INSERT sigdxvz05hsi 3065
RECEIVED OBJECT MESSAGE sigdxvz05hsi 3065
INSERT 1hgbown1i5fc9 6686
RECEIVED OBJECT MESSAGE 1hgbown1i5fc9 6686
UPDATE 9s7hmdtntgkd 4601
UPDATE 17ce0wl4ealwc 2423
UPDATE 1a96qcppjpe5f 7212
UPDATE 152pp0q3zk8zg 4671
INSERT tdlhx4yk0pmg 9733
RECEIVED OBJECT MESSAGE tdlhx4yk0pmg 9733
UPDATE 622um5vc14mq 7765
INSERT 1lsx0iiup6gg5 6041
RECEIVED OBJECT MESSAGE 1lsx0iiup6gg5 6041
UPDATE 16ekljbz9e387 4309
UPDATE 1cezkqse6hvd0 3349
UPDATE 1a6olflotven8 1087
INSERT 1au7gq4p6mv8c 3261
RECEIVED OBJECT MESSAGE 1au7gq4p6mv8c 3261
INSERT 1em7bsp3g29w 2566
RECEIVED OBJECT MESSAGE 1em7bsp3g29w 2566
INSERT 1a4mkxcpjug71 6167
RECEIVED OBJECT MESSAGE 1a4mkxcpjug71 6167
UPDATE pmw4v5xst33l 5002
UPDATE 1mpp7mfpl5kru 682
UPDATE 10z3im4emd96i 4022
UPDATE 1jxworov8e1z9 9844
INSERT 1sedtpmbhtquc 270
RECEIVED OBJECT MESSAGE 1sedtpmbhtquc 270
UPDATE lwesgdzgwpl0 8422
UPDATE gvjyxm2c7jd0 5366
INSERT moiepveyd9xt 9931
RECEIVED OBJECT MESSAGE moiepveyd9xt 9931
INSERT a8kfudlzxcxy 6156
RECEIVED OBJECT MESSAGE a8kfudlzxcxy 6156
UPDATE o0hx0zv9qgzg 3469
INSERT ugs4gnhafozq 6680
RECEIVED OBJECT MESSAGE ugs4gnhafozq 6680
INSERT sdheu51y4yfx 8489
RECEIVED OBJECT MESSAGE sdheu51y4yfx 8489
UPDATE sq6j7i0baitp 6699
INSERT v2ojrjfekv9k 4533
RECEIVED OBJECT MESSAGE v2ojrjfekv9k 4533
UPDATE 10wfve0yjl4k4 4589
INSERT uqwxetfuogwt 9849
RECEIVED OBJECT MESSAGE uqwxetfuogwt 9849
UPDATE 1ush98l72a9d3 8258
UPDATE owyg8kl65g8j 4156
INSERT pb8v2gufr6rh 6497
RECEIVED OBJECT MESSAGE pb8v2gufr6rh 6497
INSERT dmfq7qiueu7x 9955
RECEIVED OBJECT MESSAGE dmfq7qiueu7x 9955
INSERT 13ke7pnvs9ylu 7792
RECEIVED OBJECT MESSAGE 13ke7pnvs9ylu 7792
INSERT y7kbegscmisj 896
RECEIVED OBJECT MESSAGE y7kbegscmisj 896
UPDATE 2iwm9v61fvhy 749
INSERT bdmcdk1ogf9l 6628
RECEIVED OBJECT MESSAGE bdmcdk1ogf9l 6628
INSERT 18bysp3l4gb0f 6056
RECEIVED OBJECT MESSAGE 18bysp3l4gb0f 6056
UPDATE 16hr14gvrsh1k 2122
UPDATE hyp4ojojxdes 8218
UPDATE 1khy3p4q9dclk 747
UPDATE 1uzuvg1xslcky 9561
UPDATE 1kgdpavy2chez 519
INSERT 1mox60j02zh85 9798
RECEIVED OBJECT MESSAGE 1mox60j02zh85 9798
INSERT ci128g9jo27u 7739
RECEIVED OBJECT MESSAGE ci128g9jo27u 7739
INSERT 6j5syb4xpota 9066
RECEIVED OBJECT MESSAGE 6j5syb4xpota 9066
UPDATE 652v8hhke5ai 4884
UPDATE 1u1dzud98psop 2480
UPDATE q6ci13nicvri 9825
INSERT 1n81wvaep5nr6 6212
RECEIVED OBJECT MESSAGE 1n81wvaep5nr6 6212
INSERT 18ncq6m6s1acl 3285
RECEIVED OBJECT MESSAGE 18ncq6m6s1acl 3285
INSERT zjtnfrh2ajsj 3407
RECEIVED OBJECT MESSAGE zjtnfrh2ajsj 3407
UPDATE q5ug6q1daqpn 6675
INSERT uzaeixyt6g0l 610
RECEIVED OBJECT MESSAGE uzaeixyt6g0l 610
INSERT rpftez66w9rr 1695
RECEIVED OBJECT MESSAGE rpftez66w9rr 1695
UPDATE 135a8m7uhk006 4194
UPDATE 14exorxy3klbg 5424
UPDATE 14r1nopyggixk 7215
UPDATE 1izhgww1gazcn 5707
UPDATE gz1k3p3nyzcz 30
UPDATE fnf7ggv9gy8s 7314
UPDATE 2ql8f9rupz8g 1206
UPDATE 7ylaxoxi9uua 4279
INSERT x5wphn4pz0xf 7045
RECEIVED OBJECT MESSAGE x5wphn4pz0xf 7045
UPDATE b8x13s890p7v 3471
INSERT ij7897v2tqp2 8531
RECEIVED OBJECT MESSAGE ij7897v2tqp2 8531
UPDATE 1ir4dulll98sj 7765
INSERT hwiqxp6cx32v 2775
RECEIVED OBJECT MESSAGE hwiqxp6cx32v 2775
INSERT 19lblxbbkdoi0 7419
RECEIVED OBJECT MESSAGE 19lblxbbkdoi0 7419
INSERT 1dgxsd9fcwthk 6299
RECEIVED OBJECT MESSAGE 1dgxsd9fcwthk 6299
UPDATE 17owe7epcdanl 7480
UPDATE qvzncb916e1l 6856
INSERT 1c5pamjalavz0 6374
RECEIVED OBJECT MESSAGE 1c5pamjalavz0 6374
INSERT 1xndfh1zhsm8t 7993
RECEIVED OBJECT MESSAGE 1xndfh1zhsm8t 7993
INSERT 1kz8donqnnc8g 2967
RECEIVED OBJECT MESSAGE 1kz8donqnnc8g 2967
INSERT 19qq0303net89 1906
RECEIVED OBJECT MESSAGE 19qq0303net89 1906
INSERT sax47077f9ka 3016
RECEIVED OBJECT MESSAGE sax47077f9ka 3016
INSERT pufs4n4rhr1e 7255
RECEIVED OBJECT MESSAGE pufs4n4rhr1e 7255
INSERT 1e5kf8rlv0kav 5159
RECEIVED OBJECT MESSAGE 1e5kf8rlv0kav 5159
INSERT 1ulnvxkxowbly 7415
RECEIVED OBJECT MESSAGE 1ulnvxkxowbly 7415
UPDATE t9edlkta9x06 7882
UPDATE 1pkra952k87nb 2277
INSERT 1v4x4t69qoyvv 1948
RECEIVED OBJECT MESSAGE 1v4x4t69qoyvv 1948
INSERT ynlrxbwg2o86 9056
RECEIVED OBJECT MESSAGE ynlrxbwg2o86 9056
INSERT 1pjurxwpfoafo 2735
RECEIVED OBJECT MESSAGE 1pjurxwpfoafo 2735
UPDATE sxec5z2fdc8t 9386
INSERT 1po7ankt6q1e6 1401
RECEIVED OBJECT MESSAGE 1po7ankt6q1e6 1401
UPDATE 10wjk2jzd5rgb 1541
UPDATE 1rs2vq5yy7603 4562
INSERT 12l3q5i8xcyem 6099
RECEIVED OBJECT MESSAGE 12l3q5i8xcyem 6099
INSERT 105ia9hr5xg3t 4083
RECEIVED OBJECT MESSAGE 105ia9hr5xg3t 4083
INSERT naup4tcu7c2w 9001
RECEIVED OBJECT MESSAGE naup4tcu7c2w 9001
INSERT r97pmgdg7z4y 4698
RECEIVED OBJECT MESSAGE r97pmgdg7z4y 4698
INSERT 11bba4337czby 444
RECEIVED OBJECT MESSAGE 11bba4337czby 444
INSERT lcodtofso3fy 3621
RECEIVED OBJECT MESSAGE lcodtofso3fy 3621
INSERT o2l983w9jov8 8912
RECEIVED OBJECT MESSAGE o2l983w9jov8 8912
INSERT 1urnou35ulywu 697
RECEIVED OBJECT MESSAGE 1urnou35ulywu 697
INSERT 1lvbw429diy7v 9018
RECEIVED OBJECT MESSAGE 1lvbw429diy7v 9018
INSERT 1p4pa3tntgroo 2444
RECEIVED OBJECT MESSAGE 1p4pa3tntgroo 2444
INSERT qxiiwynhc3gj 9248
RECEIVED OBJECT MESSAGE qxiiwynhc3gj 9248
# LOGGING CLUSTER-SERVER2
Aug 17, 2012 11:25:34 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1e701a84: startup date [Fri Aug 17 11:25:34 CEST 2012]; root of context hierarchy
Aug 17, 2012 11:25:35 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config.xml]
Aug 17, 2012 11:25:35 AM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [spring.properties]
Aug 17, 2012 11:25:35 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1e9c800e: defining beans [company,sessionfactory,datasource,propertyConfigurer,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,connectionfactory,destination,jmstemplate,org.springframework.jms.listener.DefaultMessageListenerContainer#0,companymdp]; root of factory hierarchy
Aug 17, 2012 11:25:35 AM org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager
INFO: Using JTA UserTransaction: ClientTM[cluster-server2+axis-into-ict.nl:9002+base_domain+t3+]
Aug 17, 2012 11:25:35 AM org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager
INFO: Using JTA TransactionManager: ClientTM[cluster-server2+axis-into-ict.nl:9002+base_domain+t3+]
Aug 17, 2012 11:25:35 AM org.springframework.transaction.jta.JtaTransactionManager initTransactionSynchronizationRegistry
INFO: Using JTA TransactionSynchronizationRegistry: ClientTM[cluster-server2+axis-into-ict.nl:9002+base_domain+t3+]
Aug 17, 2012 11:25:35 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Aug 17, 2012 11:25:35 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.2.Final}
Aug 17, 2012 11:25:35 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 17, 2012 11:25:35 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 17, 2012 11:25:36 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Aug 17, 2012 11:25:36 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
Aug 17, 2012 11:25:36 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Aug 17, 2012 11:25:37 AM org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup start
INFO: Starting beans in phase 2147483647
INSERT 1ro7iaej9wd9k 8795
RECEIVED OBJECT MESSAGE 1ro7iaej9wd9k 8795
INSERT 1b1fcai34faga 6314
RECEIVED OBJECT MESSAGE 1b1fcai34faga 6314
INSERT 1v57ryimse5uf 9755
RECEIVED OBJECT MESSAGE 1v57ryimse5uf 9755
INSERT yx01xew3z2jh 9354
RECEIVED OBJECT MESSAGE yx01xew3z2jh 9354
UPDATE um8jioyfz2xw 3576
UPDATE fzzhd0wiga1j 5555
UPDATE g2yjl64y5r26 9223
UPDATE 1ajjz2xwnb0xy 6102
INSERT sc8lrc1ltn1c 3679
RECEIVED OBJECT MESSAGE sc8lrc1ltn1c 3679
UPDATE 19g20kvci9lgc 3349
INSERT yekowaz2yvvv 2135
RECEIVED OBJECT MESSAGE yekowaz2yvvv 2135
UPDATE hgoeapqkrf3h 9331
INSERT qoioytyju0pd 8055
RECEIVED OBJECT MESSAGE qoioytyju0pd 8055
UPDATE q9kkzncyf9vg 5423
INSERT 1e0hjp4authf2 7252
RECEIVED OBJECT MESSAGE 1e0hjp4authf2 7252
INSERT kfuv64fpg5xh 9006
RECEIVED OBJECT MESSAGE kfuv64fpg5xh 9006
UPDATE 1bzhy6v1trxil 2834
INSERT 3jeohjlsc4ai 3093
RECEIVED OBJECT MESSAGE 3jeohjlsc4ai 3093
INSERT dlbnur9etkbu 9469
RECEIVED OBJECT MESSAGE dlbnur9etkbu 9469
UPDATE 1p02mjgb66m5c 8668
UPDATE 1nkdo6q2dok30 6031
INSERT 1memxxtvl9d7j 8365
RECEIVED OBJECT MESSAGE 1memxxtvl9d7j 8365
INSERT 18qq5qqnowk38 4747
RECEIVED OBJECT MESSAGE 18qq5qqnowk38 4747
INSERT ojxr6mn4bkpf 4212
RECEIVED OBJECT MESSAGE ojxr6mn4bkpf 4212
INSERT 1s4hpfjw4uckk 8261
RECEIVED OBJECT MESSAGE 1s4hpfjw4uckk 8261
UPDATE a7267e4nojm5 7415
UPDATE 121eduf2de5o7 1629
INSERT 1jp76tnlkkk23 5448
RECEIVED OBJECT MESSAGE 1jp76tnlkkk23 5448
INSERT b3cvx730ikth 129
RECEIVED OBJECT MESSAGE b3cvx730ikth 129
UPDATE 11pwub752h6e4 4900
INSERT 1rra35pu4kx34 5472
RECEIVED OBJECT MESSAGE 1rra35pu4kx34 5472
UPDATE 1s0zsfne0divn 4096
UPDATE 1rtoy57gl7bhu 2614
UPDATE ezzxkiss0quj 3927
UPDATE 1l9zzie9sjjwx 8543
INSERT 1hufcx719vzm1 3106
RECEIVED OBJECT MESSAGE 1hufcx719vzm1 3106
UPDATE 1wifye5nhv9fh 8054
INSERT m2e4uladi9g0 5162
RECEIVED OBJECT MESSAGE m2e4uladi9g0 5162
INSERT arag8dj5j6k8 9491
RECEIVED OBJECT MESSAGE arag8dj5j6k8 9491
UPDATE vchq9193eelj 4236
INSERT r2lu5002hm8q 3371
RECEIVED OBJECT MESSAGE r2lu5002hm8q 3371
INSERT ah5ivj9eb08g 6552
RECEIVED OBJECT MESSAGE ah5ivj9eb08g 6552
INSERT 9wbnmdm841qe 5687
RECEIVED OBJECT MESSAGE 9wbnmdm841qe 5687
INSERT m7dk38en2pa6 2771
RECEIVED OBJECT MESSAGE m7dk38en2pa6 2771
INSERT 2ccmfrlth7qi 7890
RECEIVED OBJECT MESSAGE 2ccmfrlth7qi 7890
INSERT 1j4u6kowyig5h 7865
RECEIVED OBJECT MESSAGE 1j4u6kowyig5h 7865
UPDATE 71ter5vkj56o 6106
INSERT 9o7qpmcbl4vh 1349
RECEIVED OBJECT MESSAGE 9o7qpmcbl4vh 1349
INSERT lmr4oqlu0o0o 5685
RECEIVED OBJECT MESSAGE lmr4oqlu0o0o 5685
INSERT y2du188lqyjy 1659
RECEIVED OBJECT MESSAGE y2du188lqyjy 1659
INSERT ud58jd9xkmir 4338
RECEIVED OBJECT MESSAGE ud58jd9xkmir 4338
INSERT 33sskk07r3j 2585
RECEIVED OBJECT MESSAGE 33sskk07r3j 2585
INSERT 1o3gde8i54tgt 1874
RECEIVED OBJECT MESSAGE 1o3gde8i54tgt 1874
INSERT i2ixrboywlv1 4780
RECEIVED OBJECT MESSAGE i2ixrboywlv1 4780
INSERT zwtyym43rr61 9273
RECEIVED OBJECT MESSAGE zwtyym43rr61 9273
INSERT 1im8h986ltsjb 4391
RECEIVED OBJECT MESSAGE 1im8h986ltsjb 4391
INSERT 12bcoiykhyxbz 2045
RECEIVED OBJECT MESSAGE 12bcoiykhyxbz 2045
INSERT 344m66wfi4pj 2932
RECEIVED OBJECT MESSAGE 344m66wfi4pj 2932
INSERT avu4p8rk1u49 1110
RECEIVED OBJECT MESSAGE avu4p8rk1u49 1110
INSERT 1qjb6odryerif 1602
RECEIVED OBJECT MESSAGE 1qjb6odryerif 1602
UPDATE sd8x343td04w 8207
UPDATE 1nkz2pyuxq6uf 8336
INSERT 1wd44tnl8sb21 3082
RECEIVED OBJECT MESSAGE 1wd44tnl8sb21 3082
INSERT 2osxfuuxdxbm 6578
RECEIVED OBJECT MESSAGE 2osxfuuxdxbm 6578
UPDATE 1siosbc26v8pk 3497
INSERT 136pfbsg1r4pm 6778
RECEIVED OBJECT MESSAGE 136pfbsg1r4pm 6778
INSERT 1hbb0a41y2s2v 6981
RECEIVED OBJECT MESSAGE 1hbb0a41y2s2v 6981
INSERT fqxegdpt6rl4 9823
RECEIVED OBJECT MESSAGE fqxegdpt6rl4 9823
REMOVE z66prw2lb7bp 1849
RECEIVED OBJECT MESSAGE z66prw2lb7bp 1849
INSERT 11rh97d29fhky 9445
RECEIVED OBJECT MESSAGE 11rh97d29fhky 9445
UPDATE ebh10c5v33z1 8965
UPDATE 1vd660sbipcp1 8809
UPDATE 15xnralb7gz9s 9511
INSERT 1kd8n3a1hs1e1 9622
RECEIVED OBJECT MESSAGE 1kd8n3a1hs1e1 9622
INSERT 1lrqknnl2wa9b 4794
RECEIVED OBJECT MESSAGE 1lrqknnl2wa9b 4794
INSERT 1sihm871ppxgs 5251
RECEIVED OBJECT MESSAGE 1sihm871ppxgs 5251
UPDATE 1hl9r1c3jtsww 7388
INSERT 1ktajkpo6zkrt 5676
RECEIVED OBJECT MESSAGE 1ktajkpo6zkrt 5676
UPDATE 2dja2aq45ctz 3865
INSERT 161mpey6d6vr5 4319
RECEIVED OBJECT MESSAGE 161mpey6d6vr5 4319
UPDATE 1cb45pn2a4avu 4032
UPDATE s0lllla2u71m 976
INSERT 5upsxkqis7yg 9610
RECEIVED OBJECT MESSAGE 5upsxkqis7yg 9610
UPDATE 1nz3rzwkpow1r 7827
INSERT 13vklojl41kiz 2462
RECEIVED OBJECT MESSAGE 13vklojl41kiz 2462
INSERT zdtjhvacufbe 4345
RECEIVED OBJECT MESSAGE zdtjhvacufbe 4345
UPDATE s7wc62ybsumu 1280
INSERT 4pbi0tkgevwx 8057
RECEIVED OBJECT MESSAGE 4pbi0tkgevwx 8057
INSERT 6ip3sgwf3g3v 5447
RECEIVED OBJECT MESSAGE 6ip3sgwf3g3v 5447
INSERT 2rsxw9lvikhb 5606
RECEIVED OBJECT MESSAGE 2rsxw9lvikhb 5606
INSERT ubllgdw263e 5556
RECEIVED OBJECT MESSAGE ubllgdw263e 5556
INSERT 1recoqmjit876 9174
RECEIVED OBJECT MESSAGE 1recoqmjit876 9174
INSERT sor1hnjar6c2 5791
RECEIVED OBJECT MESSAGE sor1hnjar6c2 5791
INSERT 1d7r2ebnidhwx 2335
RECEIVED OBJECT MESSAGE 1d7r2ebnidhwx 2335
INSERT 1rtu3pc4ds3t0 7070
RECEIVED OBJECT MESSAGE 1rtu3pc4ds3t0 7070
UPDATE 1s79t8kafadq1 8465
UPDATE ax93q52uqnsk 1767
REMOVE e6n7hkwvo8yp 4487
RECEIVED OBJECT MESSAGE e6n7hkwvo8yp 4487
INSERT 1j6hs0edfxrkf 8433
RECEIVED OBJECT MESSAGE 1j6hs0edfxrkf 8433
INSERT 1lcd1uj5ikznc 7508
RECEIVED OBJECT MESSAGE 1lcd1uj5ikznc 7508
UPDATE sedm4wcjn1b 8343
UPDATE 1afyqhqvum90o 9944
INSERT 1v1r9p1dqm52t 210
RECEIVED OBJECT MESSAGE 1v1r9p1dqm52t 210
INSERT sg0hnmqe4dem 1375
RECEIVED OBJECT MESSAGE sg0hnmqe4dem 1375
UPDATE 75t1sh43ixpo 3927
UPDATE vg47h8u8d22f 6993
UPDATE fck5afipv4pa 5141
UPDATE 1cyykiwoedg49 8312
INSERT f10y81rg9yml 6747
RECEIVED OBJECT MESSAGE f10y81rg9yml 6747
INSERT 7l3f1g1mee1m 1420
RECEIVED OBJECT MESSAGE 7l3f1g1mee1m 1420
INSERT m28pdjg9x95g 8483
RECEIVED OBJECT MESSAGE m28pdjg9x95g 8483
INSERT 1j8xcvo5xnpjb 7360
RECEIVED OBJECT MESSAGE 1j8xcvo5xnpjb 7360
UPDATE 1sew10cgbiejp 3257
UPDATE 16hhdy988j64o 6329
UPDATE qzsxk5twh1de 5195
UPDATE 1agu0r1l7510z 431
INSERT 637vkjsrwpi3 4456
RECEIVED OBJECT MESSAGE 637vkjsrwpi3 4456
INSERT v3ugf4y8ckrz 3271
RECEIVED OBJECT MESSAGE v3ugf4y8ckrz 3271
INSERT 1fle12g0d0zx5 8707
RECEIVED OBJECT MESSAGE 1fle12g0d0zx5 8707
INSERT 1xej9zfi0t8dm 2928
RECEIVED OBJECT MESSAGE 1xej9zfi0t8dm 2928
UPDATE pwiwzjaoubbk 8390
INSERT 1f70u0ia40x6k 401
RECEIVED OBJECT MESSAGE 1f70u0ia40x6k 401
UPDATE art5ao3f00em 9900
INSERT vn759fh7ubd0 1720
RECEIVED OBJECT MESSAGE vn759fh7ubd0 1720
INSERT 1w1bllg3eosbz 7590
RECEIVED OBJECT MESSAGE 1w1bllg3eosbz 7590
UPDATE 9pxmv4vpmddc 9141
INSERT w6nh1tlqir3t 8431
RECEIVED OBJECT MESSAGE w6nh1tlqir3t 8431
INSERT 111j0mkmjrhlr 7553
RECEIVED OBJECT MESSAGE 111j0mkmjrhlr 7553
INSERT hyg2h3m7qgd8 7779
RECEIVED OBJECT MESSAGE hyg2h3m7qgd8 7779
INSERT 14nkhq5vf2fs8 4448
RECEIVED OBJECT MESSAGE 14nkhq5vf2fs8 4448
INSERT 15xckpgp1svzs 4840
RECEIVED OBJECT MESSAGE 15xckpgp1svzs 4840
INSERT 4vtaoozysimn 7844
RECEIVED OBJECT MESSAGE 4vtaoozysimn 7844
INSERT duxumkaj9u9d 837
RECEIVED OBJECT MESSAGE duxumkaj9u9d 837
INSERT njkgl8ck5yl2 5271
RECEIVED OBJECT MESSAGE njkgl8ck5yl2 5271
INSERT 1x9ykjycto7pz 29
RECEIVED OBJECT MESSAGE 1x9ykjycto7pz 29
UPDATE 7tu7toe52nw9 8115
INSERT x1y805u22iy3 6559
RECEIVED OBJECT MESSAGE x1y805u22iy3 6559
INSERT m9pbcrb569xa 367
RECEIVED OBJECT MESSAGE m9pbcrb569xa 367
UPDATE j1oi3zdc1a9h 5242
UPDATE fiqdxeb9qmqa 1877
INSERT 302l3uigwltl 6179
RECEIVED OBJECT MESSAGE 302l3uigwltl 6179
INSERT xx85e4f0zbhy 3213
RECEIVED OBJECT MESSAGE xx85e4f0zbhy 3213
INSERT veji44ccim7q 188
RECEIVED OBJECT MESSAGE veji44ccim7q 188
INSERT sx7u7fe5gq30 6652
RECEIVED OBJECT MESSAGE sx7u7fe5gq30 6652
INSERT 1w8ryh4viycl8 4882
RECEIVED OBJECT MESSAGE 1w8ryh4viycl8 4882
INSERT 100ahar3u9h9x 2920
RECEIVED OBJECT MESSAGE 100ahar3u9h9x 2920
INSERT vwgz1hmx2ty4 72
RECEIVED OBJECT MESSAGE vwgz1hmx2ty4 72
INSERT 1erhw9czpwzpo 4113
RECEIVED OBJECT MESSAGE 1erhw9czpwzpo 4113
INSERT 95vj41irgy5u 3379
RECEIVED OBJECT MESSAGE 95vj41irgy5u 3379
INSERT 1gh5lvz2o9xnw 4171
RECEIVED OBJECT MESSAGE 1gh5lvz2o9xnw 4171
INSERT 18isrf6smcuh1 2392
RECEIVED OBJECT MESSAGE 18isrf6smcuh1 2392
INSERT 1tiek05d1byq2 511
RECEIVED OBJECT MESSAGE 1tiek05d1byq2 511
INSERT 1am7ssut5lhw6 1647
RECEIVED OBJECT MESSAGE 1am7ssut5lhw6 1647
INSERT 1mepqwdhs4a14 7800
RECEIVED OBJECT MESSAGE 1mepqwdhs4a14 7800
UPDATE 1btsuhaqfxheg 7232
INSERT 1axl8f9uwwiza 9581
RECEIVED OBJECT MESSAGE 1axl8f9uwwiza 9581
INSERT 1r8ctl0p5sojt 3607
RECEIVED OBJECT MESSAGE 1r8ctl0p5sojt 3607
UPDATE r09sraod9bdu 9494
INSERT 1oxjinecd0x1t 8898
RECEIVED OBJECT MESSAGE 1oxjinecd0x1t 8898
INSERT ubbramifgk2l 7782
RECEIVED OBJECT MESSAGE ubbramifgk2l 7782
UPDATE 1s0h223s7gmcp 5523
UPDATE 1fjirpbx38a21 4219
INSERT 7vdwh61fljb7 6492
RECEIVED OBJECT MESSAGE 7vdwh61fljb7 6492
UPDATE 4uuxh5dxormc 244
UPDATE 1wtvmom1lmwm8 9559
INSERT wu47ep5bxl2o 4597
RECEIVED OBJECT MESSAGE wu47ep5bxl2o 4597
INSERT 1icnimpttk4px 4539
RECEIVED OBJECT MESSAGE 1icnimpttk4px 4539
UPDATE 112vbkll1rj32 1642
UPDATE qub5j6dhxlqm 4851
UPDATE 90pt6t3vrrwv 5812
INSERT 1j39u3t15rvm4 8527
RECEIVED OBJECT MESSAGE 1j39u3t15rvm4 8527
UPDATE pvrxzd0n4iu7 1087
INSERT 1vzia89yavuuf 1959
RECEIVED OBJECT MESSAGE 1vzia89yavuuf 1959
INSERT 1nq2d0t41i47k 8819
RECEIVED OBJECT MESSAGE 1nq2d0t41i47k 8819
UPDATE xs8ick4ea6s2 4154
INSERT 1p0zwzuk5ah6b 5207
RECEIVED OBJECT MESSAGE 1p0zwzuk5ah6b 5207
INSERT 1gfatuxk2o62j 4241
RECEIVED OBJECT MESSAGE 1gfatuxk2o62j 4241
INSERT evgpnsmtvk5j 259
INSERT 1xliyynq7e0li 8309
RECEIVED OBJECT MESSAGE evgpnsmtvk5j 259
UPDATE 5s65mfw0uxo6 4748
RECEIVED OBJECT MESSAGE 1xliyynq7e0li 8309
UPDATE 151ot0gb16gc 7844
INSERT 9hrb8vo6bxdd 4201
RECEIVED OBJECT MESSAGE 9hrb8vo6bxdd 4201
INSERT laqk54r7rfwb 7216
RECEIVED OBJECT MESSAGE laqk54r7rfwb 7216
UPDATE 1grmm4am2frd5 7082
INSERT q2c0b960x97e 5383
RECEIVED OBJECT MESSAGE q2c0b960x97e 5383
UPDATE 1itkw8bmozyd1 8031
INSERT 1f2m3mtwe5cv8 518
RECEIVED OBJECT MESSAGE 1f2m3mtwe5cv8 518
UPDATE g5kf2dr94i2q 9129
UPDATE 14tafi90oyyc5 9494

We have also showed how a Spring Hibernate application can be migrated from JBoss AS7 to WebLogic 12c (or vice versa). The things to keep in mind when migrating Spring from one application server to another, is the classloading and how the used resources are to be configured on the application server.

References

[1] The Red Hat product reference library.
[2] JBoss Web Framework Kit 2: Spring Installation Guide for use with JBoss Web Framework Kit Edition 2.0.0.
[3] HornetQ User Manual.
[3] Spring Framework Reference Documentation.
[4] JMS (Java Message Service).


Spring and JBoss AS7 JMS

In this post we are going to look at how we can set-up a client (build using Spring) that uses the JBoss JMS provider HornetQ remotely.

Remoting

Let us first look at how we can obtain objects remotely. In the Fun with JBoss post we have created an application that contains a stateless enterprise bean. This gives us a nice playground to call this stateless enterprise bean remotely. In order to do this we can use the following program

package test;

import model.entities.Person;
import model.logic.Company;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        properties.put(Context.PROVIDER_URL, "remote://192.168.1.150:4447");
        properties.put(Context.SECURITY_PRINCIPAL, "employee");
        properties.put(Context.SECURITY_CREDENTIALS, "welcome1");
        properties.put("jboss.naming.client.ejb.context", true);

        try {
            Context context = new InitialContext(properties);
            Company company = (Company) context.lookup("LoadTest6/Model/Company!model.logic.Company");
            company.insertPerson(createPerson());
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    private static Person createPerson() {
        Person person = new Person();
        Random generator = new Random();
        person.setNaam(Long.toString(Math.abs(generator.nextLong()), 36));
        person.setSofinummer(1);
        return person;
    }
}

There are some points worth mentioning:

  • We need jboss-client-7.1.0.Final.jar in the client’s class path. The jar file can be obtained from the $JBOSS_HOME/bin/client directory of a JBoss AS7.1 distribution.
  • An application user must be created. This can be accomplished by using add-user.sh, located in the $JBOSS_HOME/bin directory. Detailed steps can be found in the Building a Coherence Cluster with Multiple Application Servers post. This user is then used to set the principal and credentials of the naming context that will be set-up.
  • Only JNDI objects prepended by java:jboss/exported/ can be obtained remotely. In the example, in which we obtain a stateless enterprise bean remotely, the object is bound as follows: app-name/module-name/bean-name!bean-interface in which,
    • app-name: the name of the .ear (without the .ear suffix) or the application name configured via application.xml deployment descriptor. If the application is not packaged in an .ear then there will be no app-name part to the JNDI string.
    • module-name: the name of the .jar or .war (without the .jar/.war suffix) in which the bean is deployed or the module-name configured in web.xml/ejb-jar.xml of the deployment. The module name is mandatory in the JNDI string.
    • bean-name: the name of the bean which by default is the simple name of the bean implementation class. It can be overridden either by using the name attribute of the bean defining annotation (@Stateless(name = "Company") in this case) or the ejb-jar.xml deployment descriptor.
    • bean-interface: the fully qualified class name of the interface being exposed by the bean.

When this is all to confusing for comfort, the logging will help, as something like the following output will be present when an application is deployed that contains enterprise beans:

16:50:52,840 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named Company in deployment unit subdeployment "Model.jar" of deployment "LoadTest6.ear" are as follows:

java:global/LoadTest6/Model/Company!model.logic.Company
java:app/Model/Company!model.logic.Company
java:module/Company!model.logic.Company
java:jboss/exported/LoadTest6/Model/Company!model.logic.Company
java:global/LoadTest6/Model/Company
java:app/Model/Company
java:module/Company

Here, we see which objects are bound under the java:jboss/exported/ name-space that can be obtained remotely. In our example, we can use context.lookup("LoadTest6/Model/Company!model.logic.Company") to obtain an instance of the enterprise bean. Note that we must not include java:jboss/exported/, as the remote-naming project expects it to always be relative to the java:jboss/exported/ name-space.

Set-up a JBoss JMS Provider

In the domain configuration file, we have the following

<domain xmlns="urn:jboss:domain:1.1">

    <extensions>
		...
        <extension module="org.jboss.as.messaging"/>
		...
    </extensions>

	<profiles>
		<profile name="cluster">
			...
		    <subsystem xmlns="urn:jboss:domain:messaging:1.1">
                <hornetq-server>
                    <persistence-enabled>true</persistence-enabled>
                    <journal-file-size>102400</journal-file-size>
                    <journal-min-files>2</journal-min-files>

                    <connectors>
                        <netty-connector name="netty" socket-binding="messaging"/>
						...
                    </connectors>

                    <acceptors>
                        <netty-acceptor name="netty" socket-binding="messaging"/>
						...
                    </acceptors>

                    <security-settings>
                        <security-setting match="#">
                            <permission type="send" roles="guest"/>
                            <permission type="consume" roles="guest"/>
                            <permission type="createNonDurableQueue" roles="guest"/>
                            <permission type="deleteNonDurableQueue" roles="guest"/>
                        </security-setting>
                    </security-settings>

					...

                    <jms-connection-factories>
						...
                        <connection-factory name="RemoteConnectionFactory">
                            <connectors>
                                <connector-ref connector-name="netty"/>
                            </connectors>
                            <entries>
                                <entry name="RemoteConnectionFactory"/>
                                <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                            </entries>
                        </connection-factory>
						...
                    </jms-connection-factories>

                    <jms-destinations>
                        <jms-queue name="testQueue">
                            <entry name="java:/queue/test"/>
                            <entry name="java:jboss/exported/jms/queue/test"/>
                        </jms-queue>
						...
                    </jms-destinations>
                </hornetq-server>
            </subsystem>
		</profile>
	</profiles>

	<interfaces>
        <interface name="management"/>
        <interface name="public"/>
        <interface name="unsecure"/>
    </interfaces>

    <socket-binding-groups>
        <socket-binding-group name="cluster-sockets" default-interface="public">
			...
            <socket-binding name="messaging" port="5445"/>
			...
        </socket-binding-group>
    </socket-binding-groups>

    <deployments>
        <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear">
            <content sha1="161f51dde7f085c822cc4c68b306d57f1bee902d"/>
        </deployment>
    </deployments>

    <server-groups>
        <server-group name="cluster-group" profile="cluster">
            <jvm name="default"/>
            <socket-binding-group ref="cluster-sockets"/>
            <deployments>
                <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear" enabled="false"/>
            </deployments>
        </server-group>
    </server-groups>

</domain>

The host configuration is set-up as follows:

<host name="jboss" xmlns="urn:jboss:domain:1.1">

    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <authentication>
                    <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
                </authentication>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <properties path="application-users.properties" relative-to="jboss.domain.config.dir" />
                </authentication>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.native.port:9999}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.http.port:9990}"/>
            </http-interface>
        </management-interfaces>
    </management>

    <domain-controller>
       <local/>
    </domain-controller>

    <interfaces>
        <interface name="management">
            <nic name="eth0"/>
        </interface>
        <interface name="public">
            <nic name="eth0"/>
        </interface>
        <interface name="unsecure">
            <inet-address value="127.0.0.1"/>
        </interface>
    </interfaces>

    <jvms>
    	<jvm name="default">
            <heap size="512m" max-size="512m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-XX:NewRatio=2"/>
                <option value="-XX:+UseParallelGC"/>
                <option value="-XX:ParallelGCThreads=2"/>
                <option value="-XX:MaxGCPauseMillis=200"/>
                <option value="-XX:GCTimeRatio=19"/>
                <option value="-XX:+UseParallelOldGC"/>
            </jvm-options>
        </jvm>
    </jvms>

    <servers>
        <server name="cluster-server1" group="cluster-group" auto-start="false">
        </server>
        <server name="cluster-server2" group="cluster-group" auto-start="false">
            <socket-bindings port-offset="1"/>
        </server>
    </servers>
</host>

Some points are worth mentioning in the above configuration:

  • In the host configuration, we have set-up two servers: cluster-server1 and cluster-server2. Note that these servers are bound to the cluster-group server group.
  • The server group is defined in the domain configuration and coupled to the cluster profile, the default JVM (defined in the host configuration), and the cluster-sockets socket binding group.
  • The default interface that cluster-sockets socket binding group uses, is the public interface. The public interface is configured to use the network interface card in this case eth0 (see the host configuration).
  • The messaging socket binding is part of the cluster-sockets socket binding group.
  • The netty connector is configured to use the messaging socket-binding.
  • The RemoteConnectionFactory is configured to use the netty connector so when a client looks up this connection factory it will receive this netty connector which will tell the client where to connect. A remark is in order: Once we get the JMS connection factory reference from the server by looking it up in JNDI and use it to create a connection, the final destination of the connection has nothing to do with the java.naming.provider.url (Context.PROVIDER_URL) that was used in the JNDI lookup. When looking up a connection factory in JNDI, the client gets a connector which is a simple stub telling the client where its connections should go. In this case the connections are bound to the network interface card and the port defined in the messaging socket binding.

Using JBoss JMS Remotely

To interact remotely with the JBoss JMS provider (HornetQ) we can use the following program to test (before we put everything into Spring)

package model.test;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

public class JNDITest {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        properties.put(Context.PROVIDER_URL, "remote://192.168.1.150:4447");
        properties.put(Context.SECURITY_PRINCIPAL, "employee");
        properties.put(Context.SECURITY_CREDENTIALS, "welcome1");

        ConnectionFactory connectionFactory = null;
        Destination destination = null;

        try {
            Context context = new InitialContext(properties);
            connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
            destination = (Destination) context.lookup("jms/queue/test");

            System.out.println(connectionFactory);
            System.out.println(destination);

            sendMessage(connectionFactory, destination);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    private static void sendMessage(ConnectionFactory connectionFactory, Destination destination) {
        Connection connection = null;
        Session session = null;
        MessageProducer messageProducer = null;

        try {
            connection = connectionFactory.createConnection("employee", "welcome1");
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            messageProducer = session.createProducer(destination);

            TextMessage text = session.createTextMessage();
            text.setText("Send some useful message");
            messageProducer.send(text);
        } catch (JMSException e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException f) {
                    f.printStackTrace();
                }
            }
        }

    }
}

One (or more) of the following exceptions can be encountered when running the program:

  1. Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
  2. Caused by: HornetQException[errorCode=105 message=Unable to validate user: null]
  3. javax.jms.JMSSecurityException: User: employee doesn’t have permission=’SEND’ on address jms.queue.test

The first exception is usually due to a host mismatch. Note that we are using the netty connector for the RemoteConnectionFactory. The netty connector uses the following (NettyConnector.java) to obtain an address:

    remoteDestination = new InetSocketAddress(host, port);
    InetAddress inetAddress = ((InetSocketAddress) remoteDestination).getAddress();

So what address would that be? To check this we can use the following

import java.net.InetAddress;

public class WhatIsMyAddress {
    public static void main(String[] args) throws Exception {
        System.out.println(InetAddress.getLocalHost());
    }
}

When this program is run we get the following output:

[jboss@axis-into-ict temp]$ /home/jboss/jdk1.6.0_31/bin/java WhatIsMyAddress
axis-into-ict.nl/192.168.1.150

When we run the test to interact with the JBoss JMS provider remotely, we get the following

Aug 10, 2012 10:48:44 AM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Aug 10, 2012 10:48:44 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Aug 10, 2012 10:48:44 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.2.GA
HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=axis-into-ict-nl], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]
HornetQQueue[testQueue]

One important thing to note here, is that the host is set to axis-into-ict-nl instead of the expected axis-into-ict.nl, i.e., in the host the ‘.’ are replaced by ‘-’. In order to get the axis-into-ict-nl to be resolved to the right IP address we add this to the etc/hosts file on the client

192.168.1.150       axis-into-ict.nl axis-into-ict-nl

The second exception is because no user is provided in the creation of a connection, i.e., connection = connectionFactory.createConnection(); is used instead of connection = connectionFactory.createConnection("employee", "welcome1").

The third exception is because the provided user to create a connection does not have the right privileges. Note that in the JMS configuration the following is present

<security-settings>
    <security-setting match="#">
        <permission type="send" roles="guest"/>
        <permission type="consume" roles="guest"/>
        <permission type="createNonDurableQueue" roles="guest"/>
        <permission type="deleteNonDurableQueue" roles="guest"/>
    </security-setting>
</security-settings>

This means the user must have the guest role. To accomplish this edit the application-roles.properties file (located in the $JBOSS_HOME/domain/configuration directory) and add the guest role to the used user, for example,

employee=guest,EMPLOYEE
manager=MANAGER

Restart the server such that the changes are picked up.

Create the Spring Client

Now that we have everything in place we can set-up the Spring configuration, for example,

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="jnditemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
                <prop key="java.naming.provider.url">remote://192.168.1.150:4447</prop>
                <prop key="java.naming.security.principal">employee</prop>
                <prop key="java.naming.security.credentials">welcome1</prop>
            </props>
        </property>
    </bean>
    <bean id="connectionfactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jnditemplate"/>
        <property name="jndiName" value="jms/RemoteConnectionFactory"/>
    </bean>
    <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jnditemplate"/>
        <property name="jndiName" value="jms/queue/test"/>
    </bean>
    <bean id="credentialsconnectionfactory"
          class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="connectionfactory"/>
        <property name="username" value="employee"/>
        <property name="password" value="welcome1"/>
    </bean>
    <bean id="jmstemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="credentialsconnectionfactory"/>
        <property name="defaultDestination" ref="destination"/>
    </bean>
    <bean class="org.springframework.jms.listener.SimpleMessageListenerContainer">
        <property name="connectionFactory" ref="credentialsconnectionfactory"/>
        <property name="destination" ref="destination"/>
        <property name="messageListener" ref="receiver"/>
    </bean>
    <bean id="sender" class="model.logic.JMSSender">
        <property name="jmsTemplate" ref="jmstemplate"/>
    </bean>
    <bean id="receiver" class="model.logic.JMSReceiver"/>
</beans>

in which, the referred classes JMSSender and JMSReceiver look as follows

package model.logic;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.Random;

public class JMSSender {

    private Random generator = new Random();
    private JmsTemplate jmsTemplate;

    public JMSSender() {
    }

    public JmsTemplate getJmsTemplate() {
        return jmsTemplate;
    }

    public void setJmsTemplate(JmsTemplate jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }

    public void sendMessage() {
        getJmsTemplate().send(new MessageCreator(){
            public Message createMessage(Session session) throws JMSException {
                TextMessage message = session.createTextMessage();
                message.setText(Long.toString(Math.abs(generator.nextLong()), 36));
                return message;
            }
        });
    }
}
package model.logic;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public class JMSReceiver implements MessageListener {
    public JMSReceiver() {
    }

    public void onMessage(Message message) {
        TextMessage text = (TextMessage)message;
        try {
            message.acknowledge();
            System.out.println("received the following message: " + text.getText());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

To test the set-up we can use

package model.test;

import model.logic.JMSSender;
import model.utils.SpringUtilities;

public class JMSTest {

    public static void main(String[] args) {
        JMSSender jmsSender = SpringUtilities.getJMSSender();

        while (true) {
            jmsSender.sendMessage();
            System.out.println("done sending message");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

When the test is run the following output is observed

Aug 10, 2012 11:19:41 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1ed2ae8: startup date [Fri Aug 10 11:19:41 CEST 2012]; root of context hierarchy
Aug 10, 2012 11:19:41 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config.xml]
Aug 10, 2012 11:19:41 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ef5502: defining beans [jnditemplate,connectionfactory,destination,credentialsconnectionfactory,jmstemplate,org.springframework.jms.listener.SimpleMessageListenerContainer#0,sender,receiver]; root of factory hierarchy
Aug 10, 2012 11:19:41 AM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Aug 10, 2012 11:19:41 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Aug 10, 2012 11:19:41 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.2.GA
Aug 10, 2012 11:19:42 AM org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver handleEnd
ERROR: Channel end notification received, closing channel Channel ID b3d15ef8 (outbound) of Remoting connection 009ffe3f to /192.168.1.150:4447
Aug 10, 2012 11:19:42 AM org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver handleEnd
ERROR: Channel end notification received, closing channel Channel ID c4cd8d30 (outbound) of Remoting connection 0032060c to /192.168.1.150:4447
Aug 10, 2012 11:19:42 AM org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup start
INFO: Starting beans in phase 2147483647
received the following message: Send some useful message
received the following message: q9em87lq59pb
done sending message
received the following message: 9l1e70x6e2yf
done sending message
received the following message: 1e0fqxcfs0os5
done sending message
received the following message: 8bcprios0t56
done sending message
received the following message: 1elnsn5m1sxf1
done sending message
received the following message: 5cnl5bt1ztp8
done sending message
received the following message: 1tnm5yf1dn6fx
done sending message
received the following message: j8efslaqykc6
done sending message
received the following message: t10r3842i2fi
done sending message
received the following message: j845q4yhyrgn
done sending message
received the following message: 4ky8mbz8h7kl
done sending message
received the following message: y5go5h1iwcl0
done sending message
received the following message: 5j6buhmnq9up
done sending message
received the following message: 1wdojt8n3kztv
done sending message
received the following message: 1k6p9352nwcgl
done sending message
received the following message: 1povempe0r3ju
done sending message

References

[1] EJB invocations from a remote client using JNDI.
[2] Remote EJB invocations via JNDI – EJB client API or remote-naming project.
[3] EJB invocations from a remote server instance.


Fun with JBoss

In this post we show a step-by-step example of how to set-up a high available tuned Java EE environment. We start with installing a Java Virtual Machine (in this case HotSpot) and JBoss Application Server. We continue with configuring a standalone server, tune the operating system and the Java Virtual Machine. Subsequently, we show how to set-up data source and JMS resources that are used by an application (consisting of a servlet, persistence, a stateless enterprise bean and a message-driven bean). Have some words about thread-pooling and enterprise beans. Show how to use the command-line interface to obtain run-time statistics. Show the steps involved in setting up a cluster by using standalone servers and configure a load balancer. Finally, we take a look at how to configure a domain in order to manage multiple server instances from a single control point.

JBoss AS7 is designed around a new kernel, which is now based on:

  • JBoss Modules – handle class loading of resources in the container. Sort of a thin bootstrap wrapper for executing an application in a modular environment.
  • Modular Service Container – provides a way to install, uninstall, and manage services used by a container. It further enables resources injection into services and dependency management between services.

Preparing the environment

Some operating system tweaks are worth considering when we do not want to run against system restrictions:

  • Packet loss minimization – The operating system buffers must be large enough to handle incoming network traffic while the application is paused during garbage collection. Usually UDP (User Datagram Protocol) is used in order to transmit multicast messages to server instances in a cluster; to limit the need to retransmit UDP messages the size of the operating system buffers must be set appropriately to avoid excessive UDP datagram loss.
  • Maximum number of open file descriptors – Most operating systems handle sockets as a form of file access and use file descriptors to keep track of which sockets are open. To contain the resources per process, the operating system restricts the number of file descriptors per process. Linux limits the number of open file descriptors per process, by default this is equal to 1024. It could be that the 1024 limit does not offer optimal performance.
  • TCP/IP – On some systems the default value for the time wait interval is too high and needs to be adjusted. When the number approaches the maximum number of file descriptors per process, the application’s throughput will degrade, i.e., new connections have to wait for a free space in the application’s file descriptor table.
  • Timesources – Linux has several timesources to choose from; the fastest being TSC (time stamp counter) and is used by default. However, if during start-up inconsistencies are found Linux switches to a slower timesource. This can have a negative performance impact.
  • Network interface card (NIC) – Configure the network card at it’s maximum link speed and at full duplex.

In the post Tuning GlassFish for Performance all the tweaks are explained in detail and the steps involved in adjusting the operating system are explained as well. The post also contains suggestions in tuning the application server and Java Virtual Machine which are applicable to the JBoss application server as well.

Installation

  • Install a JDK (of which a distribution can be downloaded here).
  • Install JBoss (of which a distribution can be downloaded here).

We will use the versions: jdk-6u31-linux-x64.bin for the JDK and jboss-as-7.1.0.Final.zip for JBoss. The installation steps are straight forward, for the JDK we can just run the bin file. JBoss can be installed by unzipping the file. When we are done we have the following directory structure:

/home/jboss
	/jboss-as-7.1.0.Final (${JBOSS_HOME)
	/jdk1.6.0_31 (${JAVA_HOME})

After the set-up, we perform a startup test to validate that there are no major problems with the Java VM/operating system combination. To test the set-up navigate to ${JBOSS_HOME}/bin and run standalone.sh. Before running standalone.sh add the following lines:

#!/bin/sh

# These lines must be added
export JAVA_HOME=/home/jboss/jdk1.6.0_31
export PATH=${PATH}:${JAVA_HOME}/bin

To set JVM parameters we can edit standalone.conf, for example,

#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
   JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
   JAVA_OPTS="$JAVA_OPTS -Djboss.server.default.config=standalone.xml"
else
   echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi

More information on tuning the JVM can be found here. Note that the default configuration is standalone.xml. This configuration does not by default include all subsystems, for example, messaging is not included. The configuration file standalone-full.xml has all the subsystems included. In the examples below we will work with standalone.xml and add specific subsystems when needed, hereby keeping the memory footprint of the application server to what is needed. When the standalone.sh is run the following is observed:

=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/jboss/jboss-as-7.1.0.Final

  JAVA: /home/jboss/jdk1.6.0_31/bin/java

  JAVA_OPTS:  -XX:+UseCompressedOops -XX:+TieredCompilation -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

=========================================================================

12:32:01,842 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
12:32:02,010 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
12:32:02,057 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
12:32:03,047 INFO  [org.xnio] XNIO Version 3.0.3.GA
12:32:03,063 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
12:32:03,078 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
12:32:03,088 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
12:32:03,145 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
12:32:03,151 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
12:32:03,212 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
12:32:03,216 INFO  [org.jboss.as.security] (MSC service thread 1-3) JBAS013100: Current PicketBox version=4.0.6.final
12:32:03,231 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
12:32:03,237 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
12:32:03,282 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
12:32:03,347 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
12:32:03,399 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
12:32:03,406 INFO  [org.jboss.as.connector] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
12:32:03,478 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
12:32:03,605 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
12:32:03,633 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.1.GA
12:32:03,716 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
12:32:03,976 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:9999
12:32:03,984 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory /home/jboss/jboss-as-7.1.0.Final/standalone/deployments
12:32:03,986 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:4447
12:32:04,119 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
12:32:04,136 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 2726ms - Started 134 of 205 services (70 services are passive or on-demand)

To verify that the server is reachable, enter the following URL: http://localhost:8080.

To use the command line interface, we can start jboss-cli.sh (also add the JAVA_HOME and PATH variables to the script). To stop the started server, we can use

[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone@localhost:9999 /] :shutdown
{"outcome" => "success"}

We can also shuwdown the server by using:

[jboss@axis-into-ict bin]$ ./jboss-cli.sh --connect command=:shutdown
{"outcome" => "success"}

When browsing through the application server folders we see that its file system is divided into two parts: standalone servers (${JBOSS_HOME}/standalone) and domain servers (${JBOSS_HOME}/domain). An application server node which is not configured as part of a domain is qualified as a standalone server.

The ${JBOSS_HOME}/bin folder is where we start application server instances. As we already saw a standalone server can be started by using standalone.sh. When using a domain we will use domain.sh, which starts the application servers specified in the domain configuration file as we will see later on. The ${JBOSS_HOME}/modules folder contains the application server’s set of libraries, which are part of the server distribution. Each module is a pluggable unit. By using a static file system approach we can load modules, all we need to do is provide the location of the modules. When looking at the standalone.sh script (line 177 and on) we see an example of how to start the server and loading modules, for example, we could use

[jboss@axis-into-ict ~]$ cd jdk1.6.0_31/bin/
[jboss@axis-into-ict bin]$ ./java -jar /home/jboss/jboss-as-7.1.0.Final/jboss-modules.jar -mp /home/jboss/jboss-as-7.1.0.Final/modules/ org.jboss.as.standalone -Djboss.home.dir=/home/jboss/jboss-as-7.1.0.Final/

The module path (-mp) argument points to the root directory which will be searched by the module loader for module definitions. A module is defined by using an XML descriptor, for example,

<module xmlns="urn:jboss:module:1.1" name="javax.jms.api">
    <dependencies>
        <module name="javax.transaction.api" export="true"/>
    </dependencies>
    <resources>
        <resource-root path="jboss-jms-api_1.1_spec-1.0.0.Final.jar"/>
        <!-- Insert resources here -->
    </resources>
</module>

A module definition contains two main elements: the module dependencies and the resources defined in the module.

When we want to use the admin console, we first have to add a user. To this end run add-user.sh (${JBOSS_HOME}/bin) and follow the instructions given on the screen, for example,

[jboss@axis-into-ict bin]$ ./add-user.sh 

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): 

Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : jboss
Password :
Re-enter Password :
About to add user 'jboss' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'jboss' to file '/home/jboss/jboss-as-7.1.0.Final/standalone/configuration/mgmt-users.properties'
Added user 'jboss' to file '/home/jboss/jboss-as-7.1.0.Final/domain/configuration/mgmt-users.properties'

Enter the following URL to access the admin console: http://hostname:9990/console and enter the log in credentials.

Configuration

The structure of the application server is maintained into a single file, which acts as a main reference for all server configurations. The default configuration files are named standalone.xml for standalone servers and domain.xml for an application server domain. An application server domain can be seen as a specialized server configuration, which also includes the domain and host controller set-up, which we will see later on. For now we will focus on the standalone configuration. The standalone.xml file is located in ${JBOSS_HOME}/standalone/configuration. An example looks as follows:

<server xmlns="urn:jboss:domain:1.1">
    <extensions>
        <extension module="org.jboss.as.clustering.infinispan"/>
        <extension module="org.jboss.as.configadmin"/>
		...
    </extensions>
    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <authentication>
                    <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket-binding native="management-native"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket-binding http="management-http"/>
            </http-interface>
        </management-interfaces>
    </management>
    <profile>
        <subsystem xmlns="urn:jboss:domain:logging:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:configadmin:1.0"/>
        <subsystem xmlns="urn:jboss:domain:datasources:1.0">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:ee:1.0"/>
        <subsystem xmlns="urn:jboss:domain:ejb3:1.2">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:infinispan:1.1" default-cache-container="hibernate">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
        <subsystem xmlns="urn:jboss:domain:jca:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
        <subsystem xmlns="urn:jboss:domain:jmx:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:jpa:1.0">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:mail:1.0">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:naming:1.1"/>
        <subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="lazy">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:pojo:1.0"/>
        <subsystem xmlns="urn:jboss:domain:remoting:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0"/>
        <subsystem xmlns="urn:jboss:domain:sar:1.0"/>
        <subsystem xmlns="urn:jboss:domain:security:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:threads:1.1"/>
        <subsystem xmlns="urn:jboss:domain:transactions:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:webservices:1.1">...</subsystem>
        <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
    </profile>
    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
            <inet-address value="${jboss.bind.address:127.0.0.1}"/>
        </interface>
    </interfaces>
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="http" port="8080"/>
        <socket-binding name="https" port="8443"/>
        <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
        <socket-binding name="osgi-http" interface="management" port="8090"/>
        <socket-binding name="remoting" port="4447"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>
</server>

The application server contains a list of basic modules, called extensions, which are shared by all services. Extensions can be seen as a special type of module, which are used to extend the functionalities of the application server. They are stored in the ${JBOSS_HOME}/modules folder. Each extension is in turn picked up by the application server classloader at boot time, before any deployment. The application server has administration and management features that include a command-line interface (listens on port 9999) and an administration console (listens on port 9990). The profile can be seen as a collection of subsystems. Each subsystem contains a subset of functionalities used by the application server. For example, the web subsystem contains the definition of a set of connectors used by the container, the messaging subsystem defines the JMS configuration, and so on. The interfaces section contains the network interfaces and host names or IP addresses to which the application server is bound. Note that by default the server is bound to 127.0.0.1, which means it can only be reached locally. The IP address or host name can be changed at will, for example,

<interfaces>
	<interface name="management">
		<inet-address value="${jboss.bind.address.management:192.168.1.66}"/>
	</interface>
	<interface name="public">
		<inet-address value="${jboss.bind.address:192.168.1.66}"/>
	</interface>
</interfaces>

or even better gather the information from the network interface card, for example,

<interfaces>
	<interface name="management">
		<!--inet-address value="${jboss.bind.address.management:127.0.0.1}"/-->
		<nic name="eth0"/>
	</interface>
	<interface name="public">
		<!--inet-address value="${jboss.bind.address:127.0.0.1}"/-->
		<nic name="eth0"/>
	</interface>
</interfaces>

When we would now start the server the following is observed:

[jboss@axis-into-ict bin]$ ./standalone.sh
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/jboss/jboss-as-7.1.0.Final

  JAVA: /home/jboss/jdk1.6.0_31/bin/java

  JAVA_OPTS:  -XX:+UseCompressedOops -XX:+TieredCompilation -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

=========================================================================

16:29:17,748 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
16:29:17,935 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
16:29:17,983 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
16:29:18,991 INFO  [org.xnio] XNIO Version 3.0.3.GA
16:29:18,998 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
16:29:19,023 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
16:29:19,043 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
16:29:19,070 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
16:29:19,086 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
16:29:19,167 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
16:29:19,210 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
16:29:19,214 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
16:29:19,224 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.6.final
16:29:19,226 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
16:29:19,228 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
16:29:19,290 INFO  [org.jboss.as.connector] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
16:29:19,351 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
16:29:19,367 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service
16:29:19,371 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
16:29:19,586 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - Stack CXF Server 4.0.1.GA
16:29:19,694 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-3) Starting Coyote HTTP/1.1 on http--192.168.1.66-8080
16:29:19,915 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /192.168.1.66:4447
16:29:19,916 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /192.168.1.66:9999
16:29:19,949 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /home/jboss/jboss-as-7.1.0.Final/standalone/deployments
16:29:20,101 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
16:29:20,115 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 2615ms - Started 134 of 205 services (70 services are passive or on-demand)

The server is listening on another IP address than the 127.0.0.1, which is of course more useful. When using the command-line interface, we have to make sure we connect to the right host, for example,

[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
The controller is not available at localhost:9999
[disconnected /] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 /]

The command-line interface is a management tool for a domain or standalone server. It allows a user to connect to the domain controller or standalone server and execute management operations available through the de-typed management model. The native-management API is the entry point for management clients that rely on the application server’s native protocol to integrate with the management layer. It uses an open binary protocol and RPC style API based on a small number of Java types to describe and execute management operations against a domain or standalone server.

To get back at the configuration file. A socket binding makes up a named configuration of a socket. Here, we can configure the network ports, such as native management (command-line interface), which by default runs on port 9999.

Thread pools

Thread pools improve performance, and provide a means of resource management when a large number of tasks are executed asynchronously. By configuring the thread pool we can tune specific areas. The application server thread pool configuration can include:

  • A thread factory creates new threads when needed. The thread factory is not included by default in the server configuration as it relies on defaults, which in general do not need to be modified.
  • A bounded thread pool (or blocking bounded thread pool) is the most common kind of pool used by the application server, as it prevents resource exhaustion by defining a constraint on the thread pool size. This thread pool is also the most complex, i.e., it has to maintain a fixed-length queue and two pool sizes (core size and maximum size). When a new task is submitted, a new thread is created when the number of running threads is less than the core size. Otherwise, if there is room in the queue, the task is queued. When none of these options apply, the executor can create a new thread when the maximum size is not yet reached, otherwise the task can either be blocked (in the case of a blocking bounded thread pool) until there is room in the queue or it can be passed to a so-called hand-off executor (when one is specified, otherwise the task will be rejected).
  • A unbounded thread pool has a core size and a queue with no upper bound. When a task is submitted and the number of running threads is less than the core size, a new thread is created. Otherwise, the task is placed in a queue. If too many tasks are submitted, an out of memory error can occur.
  • A queueless thread pool (or blocking queueless thread pool) is a thread pool with no queue and has the same logic as the bounded thread pool (without the queue storage option).
  • A scheduled thread pool is used for activities on the server-side that require running periodically or with delays.

An example configuration looks as follows

<subsystem xmlns="urn:jboss:domain:threads:1.1">
	<blocking-bounded-queue-thread-pool name="http-thread-pool">
		<queue-length count="500" per-cpu="200"/>
		<core-threads count="5" per-cpu="2"/>
		<max-threads count="10" per-cpu="3"/>
		<keepalive-time time="30" unit="seconds"/>
	</blocking-bounded-queue-thread-pool>
</subsystem>

In the configuration above we did not define a thread-factory. By not defining a thread-factory an appropriate default thread factory will be used. To view the configuration we can use the following (note that by using read-resource-description we get a detailed description of all the elements the can be configured)

[standalone@192.168.1.66:9999 /] /subsystem=threads/blocking-bounded-queue-thread-pool=http-thread-pool:read-resource-description
{
    "outcome" => "success",
    "result" => {
        "description" => "A thread pool executor with a bounded queue where threads submittings tasks may block. Such a thread pool has a core and maximum size and a specified queue length.  When a task is submitted, if the number of running threads is less than the core size, a new thread is created.  Otherwise, if there is room in the queue, the task is enqueued. Otherwise, if the number of running threads is less than the maximum size, a new thread is created. Otherwise, the caller blocks until room becomes available in the queue.",
        "attributes" => {
            "core-threads" => {
                "type" => INT,
                "description" => "The core thread pool size which is smaller than the maximum pool size. If undefined, the core thread pool size is the same as the maximum thread pool size.",
                "expressions-allowed" => true,
                "nillable" => true,
                "min" => 0L,
                "max" => 2147483647L,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            },
            "current-thread-count" => {
                "type" => INT,
                "description" => "The current number of threads in the pool.",
                "expressions-allowed" => false,
                "nillable" => false,
                "access-type" => "metric",
                "storage" => "runtime"
            },
            "largest-thread-count" => {
                "type" => INT,
                "description" => "The largest number of threads that have ever simultaneously been in the pool.",
                "expressions-allowed" => false,
                "nillable" => false,
                "access-type" => "metric",
                "storage" => "runtime"
            },
            "keepalive-time" => {
                "type" => OBJECT,
                "description" => "Used to specify the amount of time that pool threads should be kept running when idle; if not specified, threads will run until the executor is shut down.",
                "expressions-allowed" => false,
                "nillable" => true,
                "value-type" => {
                    "time" => {
                        "type" => LONG,
                        "required" => true,
                        "description" => "The time"
                    },
                    "unit" => {
                        "type" => STRING,
                        "required" => true,
                        "description" => "The time unit"
                    }
                },
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            },
            "thread-factory" => {
                "type" => STRING,
                "description" => "Specifies the name of a specific thread factory to use to create worker threads. If not defined an appropriate default thread factory will be used.",
                "expressions-allowed" => false,
                "nillable" => true,
                "min-length" => 1L,
                "max-length" => 2147483647L,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "all-services"
            },
            "queue-length" => {
                "type" => INT,
                "description" => "The queue length.",
                "expressions-allowed" => true,
                "nillable" => false,
                "min" => 0L,
                "max" => 2147483647L,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "all-services"
            },
            "max-threads" => {
                "type" => INT,
                "description" => "The maximum thread pool size.",
                "expressions-allowed" => true,
                "nillable" => false,
                "min" => 0L,
                "max" => 2147483647L,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            },
            "name" => {
                "type" => STRING,
                "description" => "The name of the thread pool.",
                "expressions-allowed" => false,
                "nillable" => true,
                "min-length" => 1L,
                "max-length" => 2147483647L,
                "access-type" => "read-only",
                "storage" => "configuration"
            },
            "rejected-count" => {
                "type" => INT,
                "description" => "The number of tasks that have been passed to the handoff-executor (if one is specified) or discarded.",
                "expressions-allowed" => false,
                "nillable" => false,
                "access-type" => "metric",
                "storage" => "runtime"
            },
            "allow-core-timeout" => {
                "type" => BOOLEAN,
                "description" => "Whether core threads may time out.",
                "expressions-allowed" => false,
                "nillable" => true,
                "default" => false,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            }
        },
        "operations" => undefined,
        "children" => {}
    }
}
[standalone@192.168.1.66:9999 /] /subsystem=threads/blocking-bounded-queue-thread-pool=http-thread-pool:read-resource
{
    "outcome" => "success",
    "result" => {
        "allow-core-timeout" => false,
        "core-threads" => 50,
        "keepalive-time" => {
            "time" => 10L,
            "unit" => "SECONDS"
        },
        "max-threads" => 50,
        "name" => "http-thread-pool",
        "queue-length" => 50,
        "thread-factory" => undefined
    }
}

Data source

A note up front is in order. When installing and configuring an Oracle database on, for example, a Windows machine, it usually is bound to localhost. To change this, we have to edit listener.ora and tnsnames.ora (both are located in ${ORACLE_HOME}/product/11.2.0/dbhome_1/NETWORK/ADMIN). For example,

# listener.ora Network Configuration File: c:\oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = c:\oracle\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:c:\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = c:\oracle
# tnsnames.ora Network Configuration File: c:\oracle\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL11 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl11)
    )
  )

LISTENER_ORCL11 =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521))

The procedure for installing a new module requires copying the .jar libraries in the appropriate modules path and adding a module.xml file, which declares the module and its dependencies. For the module path we are going to use ${JBOSS_HOME}/modules/${MODULE}/main, in which ${MODULE} will be com/oracle/database. We have the following directory structure

${JBOSS_HOME}/modules
	/com/oracle/database
		/main
			module.xml
			ojdbc6.jar

The contents of module.xml are the following

<module xmlns="urn:jboss:module:1.1" name="com.oracle.database">
    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

To configure a data source, find the entry subsystem xmlns="urn:jboss:domain:datasources:1.0" in standalone.xml, and add the following:

<subsystem xmlns="urn:jboss:domain:datasources:1.0">
	<datasources>
		<datasource jndi-name="java:/jdbc/OracleDS" pool-name="OracleDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
			<connection-url>jdbc:oracle:thin:@192.168.1.65:1521:orcl11</connection-url>
			<driver>oracle</driver>
			<pool>
				<min-pool-size>1</min-pool-size>
				<max-pool-size>15</max-pool-size>
				<prefill>true</prefill>
				<use-strict-min>true</use-strict-min>
		    </pool>
			<security>
				<user-name>example</user-name>
				<password>example</password>
			</security>
		    <statement>
				<prepared-statement-cache-size>10</prepared-statement-cache-size>
		    </statement>
			<timeout>
				<idle-timeout-minutes>0</idle-timeout-minutes>
				<query-timeout>600</query-timeout>
		    </timeout>
		</datasource>
		<drivers>
			<driver name="oracle" module="com.oracle.database">
				<driver-class>oracle.jdbc.OracleDriver</driver-class>
				<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
		    </driver>
		</drivers>
	</datasources>
</subsystem>

When the server is started, we can check the data sources present by using the command-line interface

[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 /] /subsystem=datasources:installed-drivers-list
{
    "outcome" => "success",
    "result" => [
        {
            "driver-name" => "h2",
            "deployment-name" => undefined,
            "driver-module-name" => "com.h2database.h2",
            "module-slot" => "main",
            "driver-datasource-class-name" => "",
            "driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource",
            "driver-class-name" => "org.h2.Driver",
            "driver-major-version" => 1,
            "driver-minor-version" => 3,
            "jdbc-compliant" => true
        },
        {
            "driver-name" => "oracle",
            "deployment-name" => undefined,
            "driver-module-name" => "com.oracle.database",
            "module-slot" => "main",
            "driver-datasource-class-name" => "",
            "driver-xa-datasource-class-name" => "oracle.jdbc.xa.client.OracleXADataSource",
            "driver-class-name" => "oracle.jdbc.OracleDriver",
            "driver-major-version" => 11,
            "driver-minor-version" => 2,
            "jdbc-compliant" => true
        }
    ]
}

To test a connection

[standalone@192.168.1.66:9999 /] /subsystem=datasources/data-source=OracleDS:test-connection-in-pool
{
    "outcome" => "success",
    "result" => [true]
}

To obtain the configuration of the data source

[standalone@192.168.1.66:9999 /] /subsystem=datasources/data-source=OracleDS:read-resource
{
    "outcome" => "success",
    "result" => {
        "allocation-retry" => undefined,
        "allocation-retry-wait-millis" => undefined,
        "background-validation" => undefined,
        "background-validation-millis" => undefined,
        "blocking-timeout-wait-millis" => undefined,
        "check-valid-connection-sql" => undefined,
        "connection-properties" => undefined,
        "connection-url" => "jdbc:oracle:thin:@192.168.1.65:1521:orcl11",
        "datasource-class" => undefined,
        "driver-class" => undefined,
        "driver-name" => "oracle",
        "enabled" => true,
        "exception-sorter-class-name" => undefined,
        "exception-sorter-properties" => undefined,
        "flush-strategy" => undefined,
        "idle-timeout-minutes" => 0L,
        "jndi-name" => "java:/jdbc/OracleDS",
        "jta" => true,
        "max-pool-size" => 15,
        "min-pool-size" => 1,
        "new-connection-sql" => undefined,
        "password" => "example",
        "pool-prefill" => true,
        "pool-use-strict-min" => true,
        "prepared-statements-cache-size" => 10L,
        "query-timeout" => 600L,
        "reauth-plugin-class-name" => undefined,
        "reauth-plugin-properties" => undefined,
        "security-domain" => undefined,
        "set-tx-query-timeout" => "false",
        "share-prepared-statements" => "false",
        "spy" => "false",
        "stale-connection-checker-class-name" => undefined,
        "stale-connection-checker-properties" => undefined,
        "track-statements" => "\"NOWARN\"",
        "transaction-isolation" => undefined,
        "url-delimiter" => undefined,
        "url-selector-strategy-class-name" => undefined,
        "use-ccm" => true,
        "use-fast-fail" => "false",
        "use-java-context" => true,
        "use-try-lock" => undefined,
        "user-name" => "example",
        "valid-connection-checker-class-name" => undefined,
        "valid-connection-checker-properties" => undefined,
        "validate-on-match" => "false",
        "statistics" => {
            "pool" => undefined,
            "jdbc" => undefined
        }
    }
}

JMS

The JMS server configuration is done through the messaging subsystem. Which is not enabled when the default standalone.xml configuration is used. To enable the messaging subsystem we add the following to the standalone.xml configuration file (note that this can be copied from standalone-full.xml)

<server xmlns="urn:jboss:domain:1.1">
    <extensions>
		...
        <extension module="org.jboss.as.messaging"/>
		...
    </extensions>
    <management>...</management>
    <profile>
		...
        <subsystem xmlns="urn:jboss:domain:messaging:1.1">
            <hornetq-server>
                <persistence-enabled>true</persistence-enabled>
                <journal-file-size>102400</journal-file-size>
                <journal-min-files>2</journal-min-files>
                <connectors>
                    <netty-connector name="netty" socket-binding="messaging"/>
                    <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                    </netty-connector>
                    <in-vm-connector name="in-vm" server-id="0"/>
                </connectors>
                <acceptors>
                    <netty-acceptor name="netty" socket-binding="messaging"/>
                    <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                        <param key="direct-deliver" value="false"/>
                    </netty-acceptor>
                    <in-vm-acceptor name="in-vm" server-id="0"/>
                </acceptors>
                <security-settings>
                    <security-setting match="#">
                        <permission type="send" roles="guest"/>
                        <permission type="consume" roles="guest"/>
                        <permission type="createNonDurableQueue" roles="guest"/>
                        <permission type="deleteNonDurableQueue" roles="guest"/>
                    </security-setting>
                </security-settings>
                <address-settings>
                    <address-setting match="#">
                        <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                        <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                        <redelivery-delay>0</redelivery-delay>
                        <max-size-bytes>10485760</max-size-bytes>
                        <address-full-policy>BLOCK</address-full-policy>
                        <message-counter-history-day-limit>10</message-counter-history-day-limit>
                    </address-setting>
                </address-settings>
                <jms-connection-factories>
                    <connection-factory name="InVmConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/ConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <connection-factory name="RemoteConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="netty"/>
                        </connectors>
                        <entries>
                            <entry name="RemoteConnectionFactory"/>
                            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <pooled-connection-factory name="hornetq-ra">
                        <transaction mode="xa"/>
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/JmsXA"/>
                        </entries>
                    </pooled-connection-factory>
                </jms-connection-factories>
                <jms-destinations>
                    <jms-queue name="testQueue">
                        <entry name="java:/queue/test"/>
                        <entry name="java:jboss/exported/jms/queue/test"/>
                    </jms-queue>
                    <jms-topic name="testTopic">
                        <entry name="java:/topic/test"/>
                        <entry name="java:jboss/exported/jms/topic/test"/>
                    </jms-topic>
                </jms-destinations>
            </hornetq-server>
        </subsystem>
    </profile>
    <interfaces>...</interfaces>
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
	    ...
        <socket-binding name="messaging" port="5445"/>
        <socket-binding name="messaging-throughput" port="5455"/>
		...
    </socket-binding-group>
</server>

The transport of JMS messages is a key part of messaging system tuning. HornetQ uses Netty (a NIO client server framework) as its network library. The HornetQ transports configuration consist of acceptors and connectors. An acceptor defines which type of connection is accepted by the HornetQ server. A connector defines how to connect to a HornetQ server. HornetQ defines two the following types:

  • In-VM (Intra Virtual Machine) – can be used when both HornetQ client and server run in the same virtual machine.
  • netty – used when HornetQ client and server run in different virtual machines.

The JMS connection factories can be split into two kinds: In-VM connections and connections factories that can be used by remote clients. Each connection factory does reference a connector declaration, that is associated with a socket binding. The connection factory entry declaration specifies the JNDI name under which the factory will be exposed. Queues and topics are sub resources of the messaging subsystem. Each entry refers to a JNDI name of the queue or topic.

To check the configuration when the server is restarted, we can use

[standalone@192.168.1.66:9999 /] /subsystem=messaging/hornetq-server=default/connection-factory=InVmConnectionFactory:read-resource
{
    "outcome" => "success",
    "result" => {
        "auto-group" => false,
        "block-on-acknowledge" => false,
        "block-on-durable-send" => true,
        "block-on-non-durable-send" => false,
        "cache-large-message-client" => false,
        "call-timeout" => 30000L,
        "client-failure-check-period" => 30000L,
        "client-id" => undefined,
        "compress-large-messages" => false,
        "confirmation-window-size" => -1,
        "connection-load-balancing-policy-class-name" => "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy",
        "connection-ttl" => 60000L,
        "connector" => {"in-vm" => undefined},
        "consumer-max-rate" => -1,
        "consumer-window-size" => 1048576,
        "discovery-group-name" => undefined,
        "discovery-initial-wait-timeout" => undefined,
        "dups-ok-batch-size" => 1048576,
        "entries" => ["java:/ConnectionFactory"],
        "failover-on-initial-connection" => false,
        "failover-on-server-shutdown" => undefined,
        "group-id" => undefined,
        "ha" => false,
        "max-retry-interval" => 2000L,
        "min-large-message-size" => 102400,
        "pre-acknowledge" => false,
        "producer-max-rate" => -1,
        "producer-window-size" => 65536,
        "reconnect-attempts" => 0,
        "retry-interval" => 2000L,
        "retry-interval-multiplier" => 1.0,
        "scheduled-thread-pool-max-size" => 5,
        "thread-pool-max-size" => -1,
        "transaction-batch-size" => 1048576,
        "use-global-pools" => true
    }
}

[standalone@192.168.1.66:9999 /] /subsystem=messaging/hornetq-server=default/jms-queue=testQueue:read-resource
{
    "outcome" => "success",
    "result" => {
        "durable" => true,
        "entries" => [
            "java:/queue/test",
            "java:jboss/exported/jms/queue/test"
        ],
        "selector" => undefined
    }
}

Enterprise beans

By default, the following configuration is present

<subsystem xmlns="urn:jboss:domain:ejb3:1.2">
	<session-bean>
		<stateless>
			<bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
		</stateless>
		<stateful default-access-timeout="5000" cache-ref="simple"/>
		<singleton default-access-timeout="5000"/>
	</session-bean>
	<mdb>
		<resource-adapter-ref resource-adapter-name="hornetq-ra"/>
		<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
	</mdb>
	<pools>
		<bean-instance-pools>
			<strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
			<strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
		</bean-instance-pools>
	</pools>
	<caches>
		<cache name="simple" aliases="NoPassivationCache"/>
		<cache name="passivating" passivation-store-ref="file" aliases="SimpleStatefulCache"/>
	</caches>
	<passivation-stores>
		<file-passivation-store name="file"/>
	</passivation-stores>
	<async thread-pool-name="default"/>
	<timer-service thread-pool-name="default">
		<data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
	</timer-service>
	<remote connector-ref="remoting-connector" thread-pool-name="default"/>
	<thread-pools>
		<thread-pool name="default">
			<max-threads count="10"/>
			<keepalive-time time="100" unit="milliseconds"/>
		</thread-pool>
	</thread-pools>
</subsystem>

One of the key responsibilities of the EJB container is the management of EJB component lifecycles. Bean instances are pooled and reused by the container to reduce the number of object instantiations. For example the lifecycle of a stateless session bean is as follows:

  • The client obtains a reference to the stateless session bean. There are three options here. First, the reference can be injected into the client via an @EJB annotation. Second, the reference can be bound into the client’s local java:comp/env environment, using the @EJB annotation at class-level or a deployment descriptor entry, and the client can retrieve the reference with a JNDI lookup. Third, the client can look up the stateless session bean in the server’s global JNDI tree.
  • The client invokes a business method on the bean reference.
  • The container can reuse an existing instance of the stateless session bean from a pool, if available, or can instantiate a new bean instance. If a bean instance is newly created, the container will first perform dependency injection. If the stateless session bean implements the optional javax.ejb.SessionBean interface, the container will call setSessionContext. The session context will also be injected to any SessionContext field marked with the @Resource annotation. After completing injection of the session context and other dependencies, the container will call any methods marked with the @PostConstruct annotation.
  • The container starts a transaction, if appropriate. This is controlled by the @javax.ejb.TransactionManagement and @javax.ejb.TransactionAttribute annotations.
  • The container invokes the called business method on the bean instance, and the bean performs the desired operation.
  • The container commits the transaction, if appropriate.
  • The results of the business method call are returned to the client.
  • The client may invoke additional business methods on the bean reference, each of which may end up invoking methods on a different bean instance.
  • At some point, if the container decides to reduce the size of the bean instance pool, the container invokes any @PreDestroy methods on the bean instance, or ejbRemove if the bean implements the SessionBean interface. It is important to understand that this decision is not related to any client action.

There is a stronger link between the lifecycle of a stateful session bean and the client’s use of its reference:

  • The client obtains a reference to the stateful session bean.
  • The container instantiates a new bean instance. The container will perform dependency injection. If the stateful session bean implements the optional javax.ejb.SessionBean interface, the container will call setSessionContext. The session context will also be injected to any SessionContext field marked with the @Resource annotation. Any methods marked with the @PostConstruct will then be called.
  • The client invokes a business method on the bean reference.
  • The container starts a transaction, if appropriate.
  • The container invokes a business method on the bean instance, and the bean performs the desired operation.
  • The container commits the transaction, if appropriate.
  • The results of the business method call are returned to the client.
  • The client may invoke additional business methods on the bean reference and is assured that these additional calls will go to the same instance of the bean.
  • The client calls a method annotated with @javax.ejb.Remove when it is done with the stateful session bean.
  • The container invokes any @PreDestroy methods on the bean instance, or ejbRemove if the bean implements the SessionBean interface.

This introduction to the lifecycle of session EJB components represents a simplified view of the process. Additional complexities are introduced by limitations in the pool and cache sizes that we need to understand to configure the application properly.

EJB Pooling – JBoss maintains a pool of stateless session EJB instances for each stateless session bean deployment. This pool improves performance, because a client request can be handled immediately by any free initialized EJB instance. By default, the pool starts empty, and grows on demand. This can be controlled with the max-pool-size parameter. Within the pool configuration, there is also set a instance-acquisition-timeout of 5 minutes, which will come into play if the number of requests are larger than the maximum number of beans in the pool. If we set max-pool-size, we are choosing deliberately to throttle the application. If there are no idle bean instances, an thread making a new request will block until a bean becomes available or the transaction times out (so it must not be set too low). Message-driven beans are pooled in a manner very similar to stateless session beans. The number of message-driven bean instances can be controlled by using the max-pool-size parameter.

Stateful session bean instances are created as they are needed to service client requests. Between requests these instances reside in a bean-specific cache in the active state, ready for the next request. The size of the cache is limited by the max-size element (which is available for a passivation store). So long as the application never requires more than max-size instances of the stateful session bean at any given time to service all concurrent clients, there is no contention for the cache and performance is optimal. If we limit the number of beans in the cache, the managing of the cache is fairly active:

  • If the cache is full, bean instances that are not being used at that moment for client requests are subject to passivation.
  • If bean-managed transaction demarcation is used, a transaction may not be committed or rolled back at the end of a business method call. This leaves the bean instance associated with the transaction, pinned in the cache, and not eligible for passivation. Applications that keep transactions open between stateful session bean calls do not scale well and are difficult to manage.
  • Passivation logic is controlled by the cache type; least recently used (LRU), passivates based the max-size and the time when the bean has not been used; not recently used (NRU), passivates beans only when the number of active beans approaches the max-size setting. The NRU strategy is lazy; the LRU strategy is eager. Although the LRU setting can be a convenient way of enforcing idle timeouts on the resources the objects encapsulate, it requires the cache to keep track of the bean’s access time and maintain an ordered list that gets updated after each bean access. Unless we have a good reason to need idle timeouts strictly enforced, most applications should probably use the NRU algorithm.

Passivation of beans means serialization of non-transient data in the bean to disk storage to release the memory used by the bean. The next request for the passivated bean will require activation, the reverse process, where bean elements are read from the disk store and the active bean instance is recreated in memory. Needless to say, passivation and activation cycles can be extremely expensive. The application should always call a @Remove method to delete the active bean instance from the cache when a client is through using the instance. Failure to call a @Remove method leaves the bean instance in the active state and consumes one slot in the cache, requiring eventual passivation during cache management to make room for additional client beans.

By using the command-line interface we retrieve some configuration information, for example,

[standalone@192.168.1.66:9999 /] /subsystem=ejb3:read-resource
{
    "outcome" => "success",
    "result" => {
        "cluster-passivation-store" => undefined,
        "default-clustered-sfsb-cache" => undefined,
        "default-entity-bean-instance-pool" => undefined,
        "default-entity-bean-optimistic-locking" => undefined,
        "default-mdb-instance-pool" => "mdb-strict-max-pool",
        "default-resource-adapter-name" => "hornetq-ra",
        "default-sfsb-cache" => "simple",
        "default-singleton-bean-access-timeout" => 5000L,
        "default-slsb-instance-pool" => "slsb-strict-max-pool",
        "default-stateful-bean-access-timeout" => 5000L,
        "in-vm-remote-interface-invocation-pass-by-value" => "true",
        "cache" => {
            "simple" => undefined,
            "passivating" => undefined
        },
        "file-passivation-store" => {"file" => undefined},
        "service" => {
            "timer-service" => undefined,
            "remote" => undefined,
            "async" => undefined
        },
        "strict-max-bean-instance-pool" => {
            "slsb-strict-max-pool" => undefined,
            "mdb-strict-max-pool" => undefined
        },
        "thread-pool" => {"default" => undefined}
    }
}

To get insight in the file passivation configuration we can use

[standalone@192.168.1.66:9999 /] /subsystem=ejb3/file-passivation-store=file:read-resource
{
    "outcome" => "success",
    "result" => {
        "groups-path" => "ejb3/groups",
        "idle-timeout" => 300L,
        "idle-timeout-unit" => "SECONDS",
        "max-size" => 100000,
        "name" => "file",
        "relative-to" => "jboss.server.data.dir",
        "sessions-path" => "ejb3/sessions",
        "subdirectory-count" => 100
    }
}

Or the stateless session bean pool configuration

[standalone@192.168.1.66:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=slsb-strict-max-pool:read-resource
{
    "outcome" => "success",
    "result" => {
        "max-pool-size" => 20,
        "name" => "slsb-strict-max-pool",
        "timeout" => 5L,
        "timeout-unit" => "MINUTES"
    }
}

Application

The application consists of a servlet that calls a stateless enterprise bean, which in turn (based on the task to be performed); inserts data in the database and sends a message to the queue; updates data in the database; or removes data from the database and also sends a message to the queue. We have to following persistence configuration,

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
    <persistence-unit name="PersonPersistenceUnit">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:/jdbc/OracleDS</jta-data-source>
        <class>model.entities.Person</class>
    </persistence-unit>
</persistence>

Note that in JBoss, Hibernate is the default persistence provider and we do not need to include the classes as these are already present on the application server. The jta-data-source is mapped to the data source we have configured above with a JNDI name of java:/jdbc/OracleDS. The stateless enterprise bean looks as follows

package model.logic;

import model.entities.Person;

import javax.ejb.Remote;

@Remote
public interface Company {
    public void insertPerson(Person person);

    public void removePerson(Integer sofinummer);

    public void updatePerson(Person person);
}

and has the following implementation

package model.logic;

import model.entities.Person;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jms.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless(name = "Company", mappedName = "Company")
public class CompanyBean implements Company {

    @PersistenceContext(unitName = "PersonPersistenceUnit")
    private EntityManager entityManager;

    @Resource(name = "java:/JmsXA")
    private ConnectionFactory connectionFactory;
    @Resource(name = "java:/queue/test")
    private Queue destination;

    private Connection connection = null;
    private Session session = null;
    private MessageProducer messageProducer = null;

    @PostConstruct
    public void init() {
        try {
            connection = connectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            messageProducer = session.createProducer(destination);
        } catch (JMSException e) {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException f) {
                    e.printStackTrace();
                }
            }
        }
    }

    @PreDestroy
    public void release() {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

    public void insertPerson(Person person) {
        if (findPerson(person.getSofinummer()) == null) {
            entityManager.persist(person);
            sendMessage(person);
        } else {
            updatePerson(person);
        }
    }

    public void removePerson(Integer sofinummer) {
        Person person = findPerson(sofinummer);
        if (person != null) {
            entityManager.remove(entityManager.merge(person));
            sendMessage(person);
        }
    }

    public void updatePerson(Person person) {
        entityManager.merge(person);
    }

    private Person findPerson(Integer sofinummer) {
        return entityManager.find(Person.class, sofinummer);
    }

    private void sendMessage(Person person) {
        try {
            ObjectMessage message = session.createObjectMessage();
            message.setObject(person);
            messageProducer.send(message);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

Here, we inject a JMS connection factory (with JNDI java:/JmsXA) and a JMS queue (with JNDI java:/queue/test). The enterprise bean is initialized by setting-up a message producer, that will be used in the insert and remove tasks. The message-driven bean looks as follows

@MessageDriven(name = "CompanyMDB", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/queue/test")
})
public class CompanyMDB implements MessageListener {

    public void onMessage(Message message) {
        if (message instanceof ObjectMessage) {
            ObjectMessage objectMessage = (ObjectMessage) message;
            try {
                System.out.println("RECEIVED OBJECT MESSAGE " + objectMessage.getObject());
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }

        if (message instanceof TextMessage) {
            TextMessage textMessage = (TextMessage) message;
            try {
                System.out.println("RECEIVED TEXT MESSAGE " + textMessage.getText());
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    }
}

The servlet looks as follows

package userinterface.servlets;

import model.entities.Person;
import model.logic.Company;

import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

@WebServlet(name = "TestServlet", urlPatterns = "/testservlet")
public class TestServlet extends HttpServlet {

    @EJB(name = "Company", mappedName = "java:global/LoadTest6/Model/Company")
    Company company;

    private Random generator = null;

    @Override
    public void init() throws ServletException {
        generator = new Random();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Person person = createPerson();

        if (generator.nextDouble() &lt; 0.01) {
            company.removePerson(person.getSofinummer());
        } else {
            company.insertPerson(person);
        }
    }

    @Override
    public void destroy() {
        generator = null;
    }

    private Person createPerson() {
        Person person = new Person();
        person.setNaam(Long.toString(Math.abs(generator.nextLong()), 36));
        person.setSofinummer(generator.nextInt(10000));
        return person;
    }
}

When an enterprise bean is deployed is will be bound to JNDI as java:global/<deployment-name>/<module-name>/<mapped-name>.

Deployment

In the standalone mode JBoss comes with a deployment scanner. Its job is to monitor a directory for new files and to deploy those files. In the standalone.xml configuration file the following entry can be found

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
	<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</subsystem>

To auto-deploy an application we can put our .ear or .war file into the ${JBOSS_HOME}/deployments directory. We can also use the preferred command-line interface

[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 /] deploy /home/jboss/jboss-as-7.1.0.Final/deploy/LoadTest6.ear

The following is observed in the logging

[jboss@axis-into-ict bin]$ ./standalone.sh
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/jboss/jboss-as-7.1.0.Final

  JAVA: /home/jboss/jdk1.6.0_31/bin/java

  JAVA_OPTS:  -XX:+UseCompressedOops -XX:+TieredCompilation -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

=========================================================================

13:45:06,255 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
13:45:06,420 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
13:45:06,464 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
13:45:07,295 INFO  [org.xnio] XNIO Version 3.0.3.GA
13:45:07,302 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
13:45:07,312 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
13:45:07,320 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
13:45:07,356 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
13:45:07,400 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 27) JBAS016200: Activating ConfigAdmin Subsystem
13:45:07,405 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 50) JBAS015537: Activating WebServices Extension
13:45:07,420 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 41) JBAS011940: Activating OSGi Subsystem
13:45:07,422 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 46) JBAS013101: Activating Security Subsystem
13:45:07,424 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
13:45:07,442 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.6.final
13:45:07,471 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
13:45:07,523 INFO  [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
13:45:07,546 INFO  [org.jboss.as.naming] (MSC service thread 1-4) JBAS011802: Starting Naming Service
13:45:07,645 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
13:45:07,730 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
13:45:07,773 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-3) JBoss Web Services - Stack CXF Server 4.0.1.GA
13:45:07,822 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
13:45:07,923 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http-axis-into-ict.nl-192.168.1.66-8080
13:45:07,938 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/jboss/jboss-as-7.1.0.Final/standalone/data/messagingjournal,bindingsDirectory=/home/jboss/jboss-as-7.1.0.Final/standalone/data/messagingbindings,largeMessagesDirectory=/home/jboss/jboss-as-7.1.0.Final/standalone/data/messaginglargemessages,pagingDirectory=/home/jboss/jboss-as-7.1.0.Final/standalone/data/messagingpaging)
13:45:07,946 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Waiting to obtain live lock
13:45:08,014 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageManager] (MSC service thread 1-3) Using AIO Journal
13:45:08,217 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /192.168.1.66:9999
13:45:08,250 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /home/jboss/jboss-as-7.1.0.Final/standalone/deployments
13:45:08,267 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on axis-into-ict.nl/192.168.1.66:4447
13:45:08,272 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-3) Waiting to obtain live lock
13:45:08,273 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-3) Live Server Obtained live lock
13:45:08,339 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
13:45:08,340 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:/jdbc/OracleDS]
13:45:08,649 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-3) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5445 for CORE protocol
13:45:08,651 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-3) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5455 for CORE protocol
13:45:08,652 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Server is now live
13:45:08,653 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [a0959f8b-5cbd-11e1-899c-000c2976c82d]) started
13:45:08,656 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.topic.testTopic
13:45:08,682 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/topic/test
13:45:08,683 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test
13:45:08,684 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) trying to deploy queue jms.queue.testQueue
13:45:08,689 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
13:45:08,689 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/queue/test
13:45:08,704 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
13:45:08,706 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
13:45:08,712 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
13:45:08,754 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010406: Registered connection factory java:/JmsXA
13:45:08,763 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-2) HornetQ resource adaptor started
13:45:08,763 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-2) IJ020002: Deployed: file://RaActivatorhornetq-ra
13:45:08,767 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-4) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
13:45:08,844 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 2784ms - Started 157 of 231 services (72 services are passive or on-demand)
13:46:30,698 INFO  [org.jboss.as.repository] (management-handler-threads - 6) JBAS014900: Content added at location /home/jboss/jboss-as-7.1.0.Final/standalone/data/content/16/1f51dde7f085c822cc4c68b306d57f1bee902d/content
13:46:30,714 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "LoadTest6.ear"
13:46:30,773 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "Web.war"
13:46:30,773 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "Model.jar"
13:46:30,838 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for PersonPersistenceUnit
13:46:30,961 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named Company in deployment unit subdeployment "Model.jar" of deployment "LoadTest6.ear" are as follows:

        java:global/LoadTest6/Model/Company!model.logic.Company
        java:app/Model/Company!model.logic.Company
        java:module/Company!model.logic.Company
        java:jboss/exported/LoadTest6/Model/Company!model.logic.Company
        java:global/LoadTest6/Model/Company
        java:app/Model/Company
        java:module/Company

13:46:31,177 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011402: Starting Persistence Unit Service 'LoadTest6.ear/Model.jar#PersonPersistenceUnit'
13:46:31,234 INFO  [org.jboss.as.ejb3] (MSC service thread 1-4) JBAS014142: Started message driven bean 'CompanyMDB' with 'hornetq-ra' resource adapter
13:46:31,360 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /LoadTest6
13:46:31,387 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-2) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
13:46:31,393 INFO  [org.hibernate.Version] (MSC service thread 1-2) HHH000412: Hibernate Core {4.0.1.Final}
13:46:31,397 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-2) HHH000206: hibernate.properties not found
13:46:31,398 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-2) HHH000021: Bytecode provider name : javassist
13:46:31,414 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-2) HHH000204: Processing PersistenceUnitInfo [
        name: PersonPersistenceUnit
        ...]
13:46:31,532 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-2) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
13:46:31,639 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-2) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
13:46:31,656 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-2) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
13:46:31,660 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-2) HHH000397: Using ASTQueryTranslatorFactory
13:46:31,698 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-2) Hibernate Validator 4.2.0.Final
13:46:32,054 INFO  [org.jboss.as.server] (management-handler-threads - 6) JBAS018559: Deployed "LoadTest6.ear"

When we do a few tests (access the application by using http://hostname:8080/LoadTest6/testservlet) the following is observed in the logging:

13:50:37,002 INFO  [org.jboss.ejb.client] (http-axis-into-ict.nl-192.168.1.66-8080-1) JBoss EJB Client version 1.0.2.Final
13:50:37,484 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1a0100uhg5tiu 7907
13:50:39,692 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE iuhpgb6pcs13 9223
13:50:40,164 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 6m08798r5ehs 2500
13:50:40,621 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 12wx9zs77r9cx 4262
13:50:41,044 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 6dh6zc60tw1y 285
13:50:41,850 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE extyyn0pov1w 674
13:50:42,242 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE pv0ypyftodqy 8381
13:50:42,625 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1xh0e0cn7ggsa 5954
13:50:43,026 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1fiaxr5gsxkuo 4480
13:50:43,470 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1dnmh60s6fl47 7487
13:50:43,763 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 15mxq08abiozd 6698
13:50:44,183 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE hzgxdkqw1zo7 9573
13:50:44,433 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 4mvfve8o8gfb 1940
13:50:44,810 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1skgi6orrjiaw 3535
13:50:45,066 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE vb52wrkqgx81 5712
13:50:45,598 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1rxts2saz9fhi 7821
13:50:45,697 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE j8gonmtmsd8g 4627
13:50:45,824 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE da4b2qrqpt7b 9219
13:50:45,864 INFO  [stdout] (Thread-6 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE yqlwfar66vfk 4998
13:50:45,880 INFO  [stdout] (Thread-4 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE pzqok192zmnz 7551
13:50:45,882 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE jcyf4wttbwmy 1071
13:50:45,901 INFO  [stdout] (Thread-5 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1jg4yksazwtkx 5685
13:50:45,904 INFO  [stdout] (Thread-8 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1mv38p7onaidx 4399
13:50:45,915 INFO  [stdout] (Thread-7 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE wvsj6gq17e2i 586
13:50:45,936 INFO  [stdout] (Thread-8 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1c9ij29bk00ru 3746
13:50:45,973 INFO  [stdout] (Thread-7 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE ue08qs0k9unr 6877
13:50:46,008 INFO  [stdout] (Thread-8 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE hb372i5a3dai 3762
13:50:46,048 INFO  [stdout] (Thread-7 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE cg1pr42138dr 1066
13:50:46,086 INFO  [stdout] (Thread-8 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1k28o323a0k52 3510
13:50:46,121 INFO  [stdout] (Thread-7 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE fo0pn8x69hr9 2643
13:50:46,194 INFO  [stdout] (Thread-8 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 1134xboronc8u 3323
13:50:46,235 INFO  [stdout] (Thread-7 (HornetQ-client-global-threads-1977385357)) RECEIVED OBJECT MESSAGE 16znhvr4pu6hy 5842

To obtain run-time information we can use the command-line interface, for example,

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin/
[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 /] cd subsystem=messaging/hornetq-server=default/jms-queue=testQueue
[standalone@192.168.1.66:9999 jms-queue=testQueue] pwd
/subsystem=messaging/hornetq-server=default/jms-queue=testQueue
[standalone@192.168.1.66:9999 jms-queue=testQueue] read-attribute delivering-count
0
[standalone@192.168.1.66:9999 jms-queue=testQueue] read-attribute consumer-count
15
[standalone@192.168.1.66:9999 jms-queue=testQueue] read-attribute message-count
0L
[standalone@192.168.1.66:9999 jms-queue=testQueue] read-attribute messages-added
32L
[standalone@192.168.1.66:9999 jms-queue=testQueue] cd /
[standalone@192.168.1.66:9999 /] cd subsystem=datasources/data-source=OracleDS
[standalone@192.168.1.66:9999 data-source=OracleDS] ls
connection-properties                                       statistics                                                  allocation-retry=undefined
allocation-retry-wait-millis=undefined                      background-validation=undefined                             background-validation-millis=undefined
blocking-timeout-wait-millis=undefined                      check-valid-connection-sql=undefined                        connection-url=jdbc:oracle:thin:@192.168.1.65:1521:orcl11
datasource-class=undefined                                  driver-class=undefined                                      driver-name=oracle
enabled=true                                                exception-sorter-class-name=undefined                       exception-sorter-properties=undefined
flush-strategy=undefined                                    idle-timeout-minutes=0                                      jndi-name=java:/jdbc/OracleDS
jta=true                                                    max-pool-size=15                                            min-pool-size=1
new-connection-sql=undefined                                password=example                                            pool-prefill=true
pool-use-strict-min=true                                    prepared-statements-cache-size=10                           query-timeout=600
reauth-plugin-class-name=undefined                          reauth-plugin-properties=undefined                          security-domain=undefined
set-tx-query-timeout=false                                  share-prepared-statements=false                             spy=false
stale-connection-checker-class-name=undefined               stale-connection-checker-properties=undefined               track-statements="NOWARN"
transaction-isolation=undefined                             url-delimiter=undefined                                     url-selector-strategy-class-name=undefined
use-ccm=true                                                use-fast-fail=false                                         use-java-context=true
use-try-lock=undefined                                      user-name=example                                           valid-connection-checker-class-name=undefined
valid-connection-checker-properties=undefined               validate-on-match=false
[standalone@192.168.1.66:9999 data-source=OracleDS] cd statistics=pool
[standalone@192.168.1.66:9999 statistics=pool] read-attribute AverageCreationTime
93
[standalone@192.168.1.66:9999 statistics=pool] read-attribute AvailableCount
15
[standalone@192.168.1.66:9999 statistics=pool] read-attribute ActiveCount
5
[standalone@192.168.1.66:9999 statistics=pool] read-attribute MaxWaitTime
0
[standalone@192.168.1.66:9999 statistics=pool] cd ..
[standalone@192.168.1.66:9999 data-source=OracleDS] cd statistics=jdbc
[standalone@192.168.1.66:9999 statistics=jdbc] read-attribute PreparedStatementCacheAccessCount
70
[standalone@192.168.1.66:9999 statistics=jdbc] read-attribute PreparedStatementCacheHitCount
58
[standalone@192.168.1.66:9999 statistics=jdbc] read-attribute PreparedStatementCacheMissCount
0
[standalone@192.168.1.66:9999 statistics=jdbc] cd /
[standalone@192.168.1.66:9999 /] cd deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=ejb3
[standalone@192.168.1.66:9999 subsystem=ejb3] ls
entity-bean              message-driven-bean      singleton-bean           stateful-session-bean    stateless-session-bean
[standalone@192.168.1.66:9999 subsystem=ejb3] cd message-driven-bean=CompanyMDB
[standalone@192.168.1.66:9999 message-driven-bean=CompanyMDB] read-attribute pool-current-size
2
[standalone@192.168.1.66:9999 message-driven-bean=CompanyMDB] read-attribute pool-available-count
50
[standalone@192.168.1.66:9999 message-driven-bean=CompanyMDB] cd ..
[standalone@192.168.1.66:9999 subsystem=ejb3] cd stateless-session-bean=Company
[standalone@192.168.1.66:9999 stateless-session-bean=Company] read-attribute pool-current-size
5
[standalone@192.168.1.66:9999 stateless-session-bean=Company] read-attribute pool-available-count
50
[standalone@192.168.1.66:9999 stateless-session-bean=Company] cd /
[standalone@192.168.1.66:9999 /] cd deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=jpa
[standalone@192.168.1.66:9999 subsystem=jpa] ls
hibernate-persistence-unit
[standalone@192.168.1.66:9999 subsystem=jpa] cd hibernate-persistence-unit=LoadTest6.ear\/Model.jar#PersonPersistenceUnit
[standalone@192.168.1.66:9999 hibernate-persistence-unit=LoadTest6.ear/Model.jar#PersonPersistenceUnit] ls
collection                                        entity                                            entity-cache                                      query-cache
close-statement-count=0                           collection-fetch-count=0                          collection-load-count=0                           collection-recreated-count=0
collection-remove-count=0                         collection-update-count=0                         completed-transaction-count=35                    connect-count=70
enabled=false                                     entity-delete-count=0                             entity-fetch-count=0                              entity-insert-count=0
entity-load-count=0                               entity-update-count=0                             flush-count=0                                     optimistic-failure-count=0
prepared-statement-count=70                       query-cache-hit-count=0                           query-cache-miss-count=0                          query-cache-put-count=0
query-execution-count=0                           query-execution-max-time=0                        query-execution-max-time-query-string=undefined   second-level-cache-hit-count=0
second-level-cache-miss-count=0                   second-level-cache-put-count=0                    session-close-count=0                             session-open-count=0
successful-transaction-count=35
[standalone@192.168.1.66:9999 hibernate-persistence-unit=LoadTest6.ear/Model.jar#PersonPersistenceUnit] cd ../../../
[standalone@192.168.1.66:9999 deployment=LoadTest6.ear] cd subdeployment=Web.war/subsystem=web
[standalone@192.168.1.66:9999 subsystem=web] ls
servlet                     context-root=/LoadTest6     virtual-host=default-host
[standalone@192.168.1.66:9999 subsystem=web] cd servlet=TestServlet
[standalone@192.168.1.66:9999 servlet=TestServlet] read-attribute request-count
35
[standalone@192.168.1.66:9999 servlet=TestServlet] read-attribute processing-time
2002L

For the messaging we looked at the attributes; message-count that indicates how many messages are still in the queue. For a data source it important to know if requests (tasks) are waiting for a connection from the pool. This is indicated by the max-wait-time attribute, when this differs from zero it might be useful to adjust the connection pool settings, i.e., increase the maximum number of connections in the pool when possible. Other statistics we viewed was some run-time information from the EJB and servlet environment. An alternative way to view run-time statistics is by using an MBean browser, for example, jconsole or jvisualvm. Note that in the latter case we have to install a plug-in. In jvisualvm click tools, plug-ins, available plug-ins and select visualvm-mbeans. The MBean browser has an entry jboss.as that contains all the run-time information.

We can also put the commands in a script, for example,

connect 192.168.1.66:9999
cd subsystem=messaging/hornetq-server=default/jms-queue=testQueue
pwd
read-attribute delivering-count
read-attribute consumer-count
read-attribute message-count
read-attribute messages-added
cd /
cd subsystem=datasources/data-source=OracleDS
ls
cd statistics=pool
read-attribute AverageCreationTime
read-attribute AvailableCount
read-attribute ActiveCount
read-attribute MaxWaitTime
cd ..
cd statistics=jdbc
read-attribute PreparedStatementCacheAccessCount
read-attribute PreparedStatementCacheHitCount
read-attribute PreparedStatementCacheMissCount
cd /
cd deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=ejb3
ls
cd message-driven-bean=CompanyMDB
read-attribute pool-current-size
read-attribute pool-available-count
cd ..
cd stateless-session-bean=Company
read-attribute pool-current-size
read-attribute pool-available-count
cd /
cd deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=jpa
ls
cd hibernate-persistence-unit=LoadTest6.ear\/Model.jar#PersonPersistenceUnit
ls
cd ../../../
cd subdeployment=Web.war/subsystem=web
ls
cd servlet=TestServlet
read-attribute request-count
read-attribute processing-time

To execute the script, we can use (note that we called the script example-script.cli)

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin/
[jboss@axis-into-ict bin]$ ./jboss-cli.sh --file=/home/jboss/jboss-as-7.1.0.Final/scripts/example-script.cli

Using the Apache HTTP Server as a front-end

General information about the Apache HTTP Server can be found here. When we want to use the Apache HTTP Server as a front-end and in particular mod_jk we have to enable an AJP connector for the server in question. To create a new connector requires us to declare a new socket binding first

[standalone@192.168.1.66:9999 /] /socket-binding-group=standard-sockets/socket-binding=ajp:add(port=9080)

The created socket binding can then be used to create a new connector

[standalone@192.168.1.66:9999 /] /subsystem=web/connector=ajp:add(socket-binding=ajp, protocol="AJP/1.3", enabled=true)

With the new connector in place, we can continue with setting-up the Apache HTTP server. To install the Apache HTTP server we can follow these steps

  • Unpack the httpd-2.2.21.tar.gz file:
    • gzip -d httpd-2.2.21.tar.gz
    • tar xvf httpd-2.2.21.tar
    • cd httpd-2.2.21
  • The next step is to configure:
    • ./configure –prefix=/home/jboss/apache
  • Next, compile the various parts for the Apache HTTP Server by using:
    • make
  • To install the Apache HTTP Server we use:
    • make install
  • Open the httpd.conf (/home/jboss/apache/conf) file and adjust the following directives:
    • Listen 8888
    • ServerName ip-address
  • To test the set-up, start the Apache HTTP Server:
    • Navigate to /home/jboss/apache/bin.
    • Run: ./apachectl -k start (To stop the Apache HTTP Server we can use: ./apachectl -k stop).
    • Open a browser en type the following URL: http://hostname:8888.

To install the mod_jk module we can follow these steps

  • Unpack the tomcat-connectors-1.2.32-src.tar.gz file:
    • gzip -d tomcat-connectors-1.2.32-src.tar.gz
    • tar xvf tomcat-connectors-1.2.32-src.tar
    • cd tomcat-connectors-1.2.32-src/native
  • The next step is to configure the module:
    • ./configure –with-apxs=/home/jboss/apache/bin/apxs
  • Compile:
    • make
  • In the native directory, a directory apache-2.0 is created. Here a mod_jk.so file is present. Copy this file to the directory: /home/jboss/apache/modules.

To configure the mod_jk module, create a new file mod_jk.conf in the directory /home/jboss/apache/conf. An example configuration looks as follows

LoadModule jk_module /home/jboss/apache/modules/mod_jk.so

JkWorkersFile /home/jboss/apache/conf/jboss-workers.properties

# where to put the log files for the jk module
JkLogFile /home/jboss/apache/logs/mod_jk.log

# the log level [debug|info|error]
JkLogLevel info

# log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

# options to indicate to send SSL KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# set the request log format
JkRequestLogFormat "%w %V %T"

# send requests that contain the following to JBoss
JkMount /LoadTest6/* standalone-server-worker

Next, we need to define the worker file that is specified by JkWorkersFile directive. In this case, we create a file called jboss-workers.properties in the directory /home/jboss/apache/conf. An example worker configuration is the following

# define a worker that uses ajp13
worker.list=standalone-server-worker

# set properties for the worker
worker.standalone-server-worker.type=ajp13
worker.standalone-server-worker.host=192.168.1.66 (which is the IP-address where the JBoss server is running)
worker.standalone-server-worker.port=9080 (which is AJP listen port of the JBoss Server)

To let the Apache HTTP Server pick up the configuration we add the following to the httpd.conf file

# put it near the end of the file where all the other includes are present
# mod_jk configuration
Include conf/mod_jk.conf

Restart the HTTP Server (./apachectl -k stop and ./apachectl -k start). The application can now be reached at: http://hostname:8888/LoadTest6/testservlet. Note that by using the JkMount directive, we tell mod_jk to forward requests to a configured back-end server.

We can fine tune the web container, for example,

<extensions>
	...
	<extension module="org.jboss.as.web"/>
	...
</extensions>
<profile>
	...
	<subsystem xmlns="urn:jboss:domain:web:1.1" native="false" default-virtual-server="default-host">
		<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
		<connector name="ajp" protocol="AJP/1.3" socket-binding="ajp" enabled="true" enable-lookups="false" executor="ajp-thread-pool" max-connections="150" max-post-size="1048576"/>
		<virtual-server name="default-host" enable-welcome-root="true">
			<alias name="localhost"/>
			<alias name="example.com"/>
		</virtual-server>
	</subsystem>
	...
</profile>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
	<socket-binding name="http" port="8080"/>
	<socket-binding name="https" port="8443"/>
	...
	<socket-binding name="ajp" port="9080"/>
	...
</socket-binding-group>

The connector is a Java object, which provides an interface to Web server clients. The default configuration provides a connector configuration in which most attributes have their default values. For example, to configure a denial of service we add the following attributes:

  • max-connections – the maximum number of simultaneous requests that can be made. We set this equal to the MaxClients directive configured in the Apache HTTP server.
  • max-post-size – limits the maximum size of HTTP POST requests it accepts (the default is 2MB). We set this to 1048576 (1024*1024) bytes. Note that the value is based on what post size to expect from clients. Usually for a web application this is in the range of a few kilobytes. When using web service this value can be in the range of a few 100 kilobytes depending on the message sizes the web service defines, and if attachments can be send as well.
  • max-save-post-size – maximum size of a POST that will be saved by the container during authentication (the default is 4kB which we will leave as it is).

In general, a JBoss application server will be fronted by an Apache HTTP server. One thing to note is that, we have to make the thread pool size equal to the MaxClients directive configured on the Apache HTTP Server (usually it is something like MaxClients 150) otherwise threads will pile up in the JBoss Server. An example thread pool configuration is the following.

<subsystem xmlns="urn:jboss:domain:threads:1.1">
	<blocking-bounded-queue-thread-pool name="ajp-thread-pool">
		<queue-length count="200"/>
		<core-threads count="150"/>
		<max-threads count="150"/>
		<keepalive-time time="30" unit="seconds"/>
	</blocking-bounded-queue-thread-pool>
</subsystem>

Note that when using a small pool with a large queue, we tend to minimize CPU usage, operating system resources and context switching. This can potentially lead to a low throughput. By using small queues we need larger a larger thread pool. This keeps the CPU busier and can lead to an significant increase in scheduling overhead and thereby decreasing throughput. To use a certain thread pool configuration in a connector we can use the executor attribute.

The attribute enable-lookups when set to true, a call to request.getRemoteHost() returns the actual hostname of the remote client. When set to false the IP address is returned. In the latter case no DNS lookup is performed and thus improving performance.

To check the configuration we can use

[standalone@192.168.1.66:9999 /] /subsystem=threads/blocking-bounded-queue-thread-pool=ajp-thread-pool:read-resource(recursive=true)
{
    "outcome" => "success",
    "result" => {
        "allow-core-timeout" => false,
        "core-threads" => 150,
        "keepalive-time" => {
            "time" => 30L,
            "unit" => "SECONDS"
        },
        "max-threads" => 150,
        "name" => "ajp-thread-pool",
        "queue-length" => 200,
        "thread-factory" => undefined
    }
}

[standalone@192.168.1.66:9999 /] /subsystem=web/connector=ajp:read-resource(recursive=true)
{
    "outcome" => "success",
    "result" => {
        "enable-lookups" => false,
        "enabled" => true,
        "executor" => "ajp-thread-pool",
        "max-connections" => 150,
        "max-post-size" => 1048576,
        "max-save-post-size" => 4096,
        "protocol" => "AJP/1.3",
        "redirect-port" => 8443,
        "scheme" => "http",
        "secure" => false,
        "socket-binding" => "ajp",
        "ssl" => undefined,
        "virtual-server" => undefined
    }
}

To see web metrics by using the admin console, after making a number of requests to http://hostname:8888/LoadTest6/testservlet. Open the console (http://hostname:9990/console), click the run-time tab, web in subsystem metrics and click the ajp row. It shows the request count, error count, processing time and max time.

Clustering

To cluster standalone servers we create two configuration files, for example, server1.xml and server2.xml, which are based on the standalone.xml with which we have been working. We first undeploy the LoadTest6 application, by using the command-line interface command: undeploy LoadTest6.ear. Copy the standalone.xml file twice and name the copies to server1.xml and server2.xml. To enable clustering we set the log file name for the server, enable jgroups, and make the messaging system clusterable in the configuration files

<server xmlns="urn:jboss:domain:1.1">
    <extensions>
		...
        <extension module="org.jboss.as.clustering.jgroups"/>
		...
    </extensions>
    <profile>
		<subsystem xmlns="urn:jboss:domain:logging:1.1">
			...
            <periodic-rotating-file-handler name="FILE">
                <formatter>
                    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server1.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append value="true"/>
            </periodic-rotating-file-handler>
			...
        </subsystem>
		...
        <subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="udp">
            <stack name="udp">
                <transport type="UDP" socket-binding="jgroups-udp" diagnostics-socket-binding="jgroups-diagnostics"/>
                <protocol type="PING"/>
                <protocol type="MERGE2"/>
                <protocol type="FD_SOCK" socket-binding="jgroups-udp-fd"/>
                <protocol type="FD"/>
                <protocol type="VERIFY_SUSPECT"/>
                <protocol type="BARRIER"/>
                <protocol type="pbcast.NAKACK"/>
                <protocol type="UNICAST2"/>
                <protocol type="pbcast.STABLE"/>
                <protocol type="pbcast.GMS"/>
                <protocol type="UFC"/>
                <protocol type="MFC"/>
                <protocol type="FRAG2"/>
            </stack>
            <stack name="tcp">
                <transport type="TCP" socket-binding="jgroups-tcp" diagnostics-socket-binding="jgroups-diagnostics"/>
                <protocol type="MPING" socket-binding="jgroups-mping"/>
                <protocol type="MERGE2"/>
                <protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
                <protocol type="FD"/>
                <protocol type="VERIFY_SUSPECT"/>
                <protocol type="BARRIER"/>
                <protocol type="pbcast.NAKACK"/>
                <protocol type="UNICAST2"/>
                <protocol type="pbcast.STABLE"/>
                <protocol type="pbcast.GMS"/>
                <protocol type="UFC"/>
                <protocol type="MFC"/>
                <protocol type="FRAG2"/>
            </stack>
        </subsystem>
		...
		<subsystem xmlns="urn:jboss:domain:messaging:1.1">
            <hornetq-server>
                <clustered>true</clustered>
                <cluster-user>guest</cluster-user>
                <cluster-password>guest</cluster-password>
                <persistence-enabled>true</persistence-enabled>
                <journal-type>ASYNCIO</journal-type>
                <journal-file-size>102400</journal-file-size>
                <journal-min-files>2</journal-min-files>
                <paging-directory path="messagingpaging1"/>
                <bindings-directory path="messagingbindings1"/>
                <journal-directory path="messagingjournal1"/>
                <large-messages-directory path="messaginglargemessages1"/>
                <connectors>
                    <netty-connector name="netty" socket-binding="messaging"/>
                    <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                    </netty-connector>
                    <in-vm-connector name="in-vm" server-id="0"/>
                </connectors>
                <acceptors>
                    <netty-acceptor name="netty" socket-binding="messaging"/>
                    <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                        <param key="direct-deliver" value="false"/>
                    </netty-acceptor>
                    <in-vm-acceptor name="in-vm" server-id="0"/>
                </acceptors>
                <broadcast-groups>
                    <broadcast-group name="bg-group1">
                        <group-address>231.7.7.7</group-address>
                        <group-port>9876</group-port>
                        <broadcast-period>5000</broadcast-period>
                        <connector-ref>netty</connector-ref>
                    </broadcast-group>
                </broadcast-groups>
                <discovery-groups>
                    <discovery-group name="dg-group1">
                        <group-address>231.7.7.7</group-address>
                        <group-port>9876</group-port>
                        <refresh-timeout>10000</refresh-timeout>
                    </discovery-group>
                </discovery-groups>
                <cluster-connections>
                    <cluster-connection name="my-cluster">
                        <address>jms</address>
                        <connector-ref>netty</connector-ref>
                        <discovery-group-ref discovery-group-name="dg-group1"/>
                    </cluster-connection>
                </cluster-connections>
                <security-settings>
                    <security-setting match="#">
                        <permission type="send" roles="guest"/>
                        <permission type="consume" roles="guest"/>
                        <permission type="createNonDurableQueue" roles="guest"/>
                        <permission type="deleteNonDurableQueue" roles="guest"/>
                    </security-setting>
                </security-settings>
                <address-settings>
                    <address-setting match="#">
                        <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                        <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                        <redelivery-delay>0</redelivery-delay>
                        <redistribution-delay>1000</redistribution-delay>
                        <max-size-bytes>10485760</max-size-bytes>
                        <address-full-policy>BLOCK</address-full-policy>
                        <message-counter-history-day-limit>10</message-counter-history-day-limit>
                    </address-setting>
                </address-settings>
                <jms-connection-factories>
                    <connection-factory name="InVmConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/ConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <connection-factory name="RemoteConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="netty"/>
                        </connectors>
                        <entries>
                            <entry name="RemoteConnectionFactory"/>
                            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <pooled-connection-factory name="hornetq-ra">
                        <transaction mode="xa"/>
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/JmsXA"/>
                        </entries>
                    </pooled-connection-factory>
                </jms-connection-factories>
                <jms-destinations>
                    <jms-queue name="testQueue">
                        <entry name="java:/queue/test"/>
                        <entry name="java:jboss/exported/jms/queue/test"/>
                    </jms-queue>
                    <jms-topic name="testTopic">
                        <entry name="java:/topic/test"/>
                        <entry name="java:jboss/exported/jms/topic/test"/>
                    </jms-topic>
                </jms-destinations>
            </hornetq-server>
        </subsystem>
		...
    </profile>
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
		...
        <socket-binding name="jgroups-diagnostics" port="0" multicast-address="224.0.75.75" multicast-port="7500"/>
        <socket-binding name="jgroups-mping" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
        <socket-binding name="jgroups-tcp" port="7600"/>
        <socket-binding name="jgroups-tcp-fd" port="57600"/>
        <socket-binding name="jgroups-udp" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
        <socket-binding name="jgroups-udp-fd" port="54200"/>
		...
    </socket-binding-group>
</server>

For server2 we use the port-offset attribute (which we set to one) in the socket binding

<server xmlns="urn:jboss:domain:1.1">
    <extensions>
		...
        <extension module="org.jboss.as.clustering.jgroups"/>
		...
    </extensions>
    <profile>
		<subsystem xmlns="urn:jboss:domain:logging:1.1">
			...
            <periodic-rotating-file-handler name="FILE">
                <formatter>
                    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server2.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append value="true"/>
            </periodic-rotating-file-handler>
			...
        </subsystem>
		...
        <subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="udp">...</subsystem>
		...
		<subsystem xmlns="urn:jboss:domain:messaging:1.1">
            <hornetq-server>
                <clustered>true</clustered>
                <cluster-user>guest</cluster-user>
                <cluster-password>guest</cluster-password>
                <persistence-enabled>true</persistence-enabled>
                <journal-type>ASYNCIO</journal-type>
                <journal-file-size>102400</journal-file-size>
                <journal-min-files>2</journal-min-files>
                <paging-directory path="messagingpaging2"/>
                <bindings-directory path="messagingbindings2"/>
                <journal-directory path="messagingjournal2"/>
                <large-messages-directory path="messaginglargemessages2"/>
				...
            </hornetq-server>
        </subsystem>
		...
    </profile>
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:1}">
		...
    </socket-binding-group>
</server>

To start the servers, we can use standalone.sh --server-config=server1.xml and standalone.sh --server-config=server2.xml. When the servers are started the following is shown when hornetq is connected successfully between both servers

# server1
17:24:06,129 INFO  [org.hornetq.core.server.cluster.impl.BridgeImpl] (Thread-9 (HornetQ-server-HornetQServerImpl::serverUUID=d052af0e-5efa-11e1-ad54-000c2976c82d-37774788)) Bridge ClusterConnectionBridge@4552a64d [name=sf.my-cluster.c25598f7-5efa-11e1-8e93-000c2976c82d, queue=QueueImpl[name=sf.my-cluster.c25598f7-5efa-11e1-8e93-000c2976c82d, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=d052af0e-5efa-11e1-ad54-000c2976c82d]]@35242cc9 targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@4552a64d [name=sf.my-cluster.c25598f7-5efa-11e1-8e93-000c2976c82d, queue=QueueImpl[name=sf.my-cluster.c25598f7-5efa-11e1-8e93-000c2976c82d, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=d052af0e-5efa-11e1-ad54-000c2976c82d]]@35242cc9 targetConnector=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5446&host=axis-into-ict-nl], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@762010908[nodeUUID=d052af0e-5efa-11e1-ad54-000c2976c82d, connector=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=axis-into-ict-nl, address=jms, server=HornetQServerImpl::serverUUID=d052af0e-5efa-11e1-ad54-000c2976c82d])) [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5446&host=axis-into-ict-nl], discoveryGroupConfiguration=null]] is connected

# server2
17:24:06,123 INFO  [org.hornetq.core.server.cluster.impl.BridgeImpl] (Thread-29 (HornetQ-server-HornetQServerImpl::serverUUID=c25598f7-5efa-11e1-8e93-000c2976c82d-1291383602)) Bridge ClusterConnectionBridge@4174b989 [name=sf.my-cluster.d052af0e-5efa-11e1-ad54-000c2976c82d, queue=QueueImpl[name=sf.my-cluster.d052af0e-5efa-11e1-ad54-000c2976c82d, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=c25598f7-5efa-11e1-8e93-000c2976c82d]]@5640f2f1 targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@4174b989 [name=sf.my-cluster.d052af0e-5efa-11e1-ad54-000c2976c82d, queue=QueueImpl[name=sf.my-cluster.d052af0e-5efa-11e1-ad54-000c2976c82d, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=c25598f7-5efa-11e1-8e93-000c2976c82d]]@5640f2f1 targetConnector=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=axis-into-ict-nl], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@211830739[nodeUUID=c25598f7-5efa-11e1-8e93-000c2976c82d, connector=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5446&host=axis-into-ict-nl, address=jms, server=HornetQServerImpl::serverUUID=c25598f7-5efa-11e1-8e93-000c2976c82d])) [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=axis-into-ict-nl], discoveryGroupConfiguration=null]] is connected

To deploy the application we can use the following

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin/
[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 /] deploy /home/jboss/jboss-as-7.1.0.Final/deploy/LoadTest6.ear
[standalone@192.168.1.66:9999 /] connect 192.168.1.66:10000
[standalone@192.168.1.66:10000 /] deploy /home/jboss/jboss-as-7.1.0.Final/deploy/LoadTest6.ear11

Before, we configure the load balancing, test if the application is working. Either use the URL: http://hostname:8080/LoadTest6/testservlet or the URL: http://hostname:8081/LoadTest6/testservlet.

Configure load balancing

The load balancer decides how to dispatch requests to the back end server instances. A load balancer needs to do tasks such as distributing requests, health checking and session binding. As these are simple jobs it is rare that a load balancer will become a bottleneck. To load balance requests, we are going to use mod_jk. To configure mod_jk, open the mod_jk.conf file and add the following contents:

LoadModule jk_module /home/jboss/apache/modules/mod_jk.so

JkWorkersFile /home/jboss/apache/conf/jboss-workers.properties

# where to put the log files for the jk module
JkLogFile /home/jboss/apache/logs/mod_jk.log

# the log level [debug|info|error]
JkLogLevel info

# log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

# options to indicate to send SSL KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# set the request log format
JkRequestLogFormat "%w %V %T"

# send requests that contain the following to JBoss
JkMount /LoadTest6/* loadbalancer

The workers (jboss-workers.properties) are defined as follows:

# define a worker that uses ajp13
worker.list=server1-worker,server2-worker,loadbalancer

# set properties for the server1-worker
worker.server1-worker.type=ajp13
worker.server1-worker.host=192.168.1.66
worker.server1-worker.port=9080
worker.server1-worker.lbfactor=1
worker.server1-worker.socket_keepalive=1
worker.server1-worker.socket_timeout=300

# set properties for the server2-worker
worker.server2-worker.type=ajp13
worker.server2-worker.host=192.168.1.66
worker.server2-worker.port=9081
worker.server2-worker.lbfactor=1
worker.server2-worker.socket_keepalive=1
worker.server2-worker.socket_timeout=300

# set properties for the loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=server1-worker,server2-worker

With the configuration in place, start the Apache HTTP server (./apachectl -k start) and enter the following URL: http://hostname:8888/LoadTest6/testservlet a few times to see if the requests get send to the different servers. By using the following URL’s: http://hostname:9990/console/App.html#web-metrics and http://hostname:9991/console/App.html#web-metrics, we can check how the requests are being processed. We can also use the command-line interface

[disconnected /] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 /] cd /deployment=LoadTest6.ear/subdeployment=Web.war/subsystem=web/servlet=TestServlet
[standalone@192.168.1.66:9999 servlet=TestServlet] read-attribute request-count
69
[standalone@192.168.1.66:9999 servlet=TestServlet] connect 192.168.1.66:10000
[standalone@192.168.1.66:10000 servlet=TestServlet] read-attribute request-count
68
[standalone@192.168.1.66:10000 servlet=TestServlet] read-attribute request-count
118
[standalone@192.168.1.66:10000 servlet=TestServlet] connect 192.168.1.66:9999
[standalone@192.168.1.66:9999 servlet=TestServlet] read-attribute request-count
119

As we can see the load is balanced like a charm.

Load test

We can test the environment by using the The Grinder. The following script calls the application:

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest

test1 = Test(1, "Request resource")
request1 = test1.wrap(HTTPRequest())

class TestRunner:
    def __call__(self):
        result = request1.GET("http://192.168.1.66:8888/LoadTest6/testservlet")

Edit the grinder.properties (${GRINDER_HOME}/examples) file such that the script is used, for example,

# The file name of the script to run. Relative paths are evaluated from the directory containing the properties file.
grinder.script = test.py

# The number of worker processes each agent should start.
grinder.processes = 1

# The number of worker threads each worker process should start.
grinder.threads = 1

# The number of runs each worker process will perform. When using the console set this to 0, i.e., the runs are controlled by the console.
grinder.runs = 0

Use the following scripts to start a test

setGrinderEnv.sh

#!/bin/sh
GRINDERPATH=/home/jboss/grinder-3.4
export GRINDERPATH

JAVA_HOME=/home/jboss/jdk1.6.0_31
export JAVA_HOME

USER_MEM_ARGS="-server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC"
export USER_MEM_ARGS
GRINDERPROPERTIES=${GRINDERPATH}/examples/grinder.properties
export GRINDERPROPERTIES
CLASSPATH=${GRINDERPATH}/lib/grinder.jar:${CLASSPATH}
export CLASSPATH

PATH=${JAVA_HOME}/bin:${PATH}
export PATH

startConsole.sh

#!/bin/sh
source setGrinderEnv.sh
java ${USER_MEM_ARGS} -cp ${CLASSPATH} net.grinder.Console

startAgent.sh

#!/bin/sh
source setGrinderEnv.sh
java ${USER_MEM_ARGS} -cp ${CLASSPATH} net.grinder.Grinder ${GRINDERPROPERTIES}

First start the startConsole.sh script and then start the startAgent.sh script. The agent will now wait for a start action from the console (click the action tab and then choose start processes)

By using jvisualvm or jconsole the JVM can be monitored and MBeans can browsed

We can clearly see when the load test was running. The test introduced no particular problems for the JVM. Run-time statistics from the command-line interface

server 1
subsystem=messaging/hornetq-server=default/jms-queue=testQueue
delivering-count (The number of messages that this queue is currently delivering to its consumers): 0
consumer-count (The number of consumers consuming messages from this queue): 15
message-count (The number of messages currently in this queue): 0L
messages-added (The number of messages added to this queue since it was created): 11987L

subsystem=datasources/data-source=OracleDS/statistics=pool
AverageCreationTime (The average time spent creating a physical connection): 2594
AvailableCount (The available count): 15
ActiveCount (The active count): 2
MaxWaitTime (The maximum wait time for a connection): 3

subsystem=datasources/data-source=OracleDS/statistics=jdbc
PreparedStatementCacheAccessCount (The number of times that the statement cache was accessed): 770567
PreparedStatementCacheHitCount (The number of times that statements from the cache were used): 770560
PreparedStatementCacheMissCount (The number of times that a statement request could not be satisfied with a statement from the cache): 0

deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=ejb3/message-driven-bean=CompanyMDB
pool-current-size (The current size of the pool): 4
pool-available-count (The number of available (i.e. not in use) instances in the pool): 12003

deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=ejb3/stateless-session-bean=Company
pool-current-size (The current size of the pool): 1
pool-available-count (The number of available (i.e. not in use) instances in the pool): 385348

deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=jpa/hibernate-persistence-unit=LoadTest6.ear\/Model.jar#PersonPersistenceUnit
completed-transaction-count (Number of completed transactions): 385329L
successful-transaction-count (Number of successful transactions): 385329L

deployment=LoadTest6.ear/subdeployment=Web.war/subsystem=web/servlet=TestServlet
request-count (Number of requests processed by this servlet): 385329
processing-time (Total execution time of the servlet's service method): 926143L

server 2
subsystem=messaging/hornetq-server=default/jms-queue=testQueue
delivering-count (The number of messages that this queue is currently delivering to its consumers): 0
consumer-count (The number of consumers consuming messages from this queue): 15
message-count (The number of messages currently in this queue): 0L
messages-added (The number of messages added to this queue since it was created): 11987L

subsystem=datasources/data-source=OracleDS/statistics=pool
AverageCreationTime (The average time spent creating a physical connection): 184
AvailableCount (The available count): 15
ActiveCount (The active count): 2
MaxWaitTime (The maximum wait time for a connection): 1

subsystem=datasources/data-source=OracleDS/statistics=jdbc
PreparedStatementCacheAccessCount (The number of times that the statement cache was accessed): 770566
PreparedStatementCacheHitCount (The number of times that statements from the cache were used): 770559
PreparedStatementCacheMissCount (The number of times that a statement request could not be satisfied with a statement from the cache): 0

deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=ejb3/message-driven-bean=CompanyMDB
pool-current-size (The current size of the pool): 5
pool-available-count (The number of available (i.e. not in use) instances in the pool): 12002

deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=ejb3/stateless-session-bean=Company
pool-current-size (The current size of the pool): 1
pool-available-count (The number of available (i.e. not in use) instances in the pool): 385344

deployment=LoadTest6.ear/subdeployment=Model.jar/subsystem=jpa/hibernate-persistence-unit=LoadTest6.ear\/Model.jar#PersonPersistenceUnit
completed-transaction-count (Number of completed transactions): 385325L
successful-transaction-count (Number of successful transactions): 385325L

deployment=LoadTest6.ear/subdeployment=Web.war/subsystem=web/servlet=TestServlet
request-count (Number of requests processed by this servlet): 385325
processing-time (Total execution time of the servlet's service method): 922760L

Overall the test was easily handled by the Apache HTTP server (load balancing) and the JBoss application servers present in the cluster.

Domains

One of the new features of JBoss AS 7 is the ability to manage multiple server instances from a single control point. A domain controller process is acting as the management point. All the server instances share a common management policy, with the domain controller acting to ensure that each server is configured according to that policy. Domains can span multiple machines, with server instances on a certain host under the control of a host controller process. One host controller instance is configured as the domain controller. The host controller on each host interacts with the domain controller to control the lifecycle of the server instances running on a particular host and to assist the domain controller in managing them. One thing to note is that the configuration of subsystems (such as messaging and data sources) within a profile does not differ from the standalone configuration (apart from the fact that a domain configuration can have multiple profiles whereas a standalone configuration can only have one). What we need to get the hang of when working with domains are the domain and host controller configurations.

When the ${JBOSS_HOME}/bin/domain.sh script is run a host controller process is started. The host controller starts and stops server instances on the particular host where it was started. Each host controller is configured by using the ${JBOSS_HOME}/domain/configuration/host.xml file. This file contains

  • The list of application server names that must run on the host.
  • The configuration how the host controller must contact the domain controller to register itself and access the domain configuration. This can either be how to contact a remote domain controller or telling the host controller to act itself as a domain controller.

As already mentioned one host controller must act as the domain controller (central management point). The domain controller maintains a central management policy and makes sure the host controllers are aware of the contents. It also make sure that each server instance is configured with respect to the central management policy. The central management policy is by default stored in the ${JBOSS_HOME}/domain/configuration/domain.xml file on the filesystem where the domain controller is present (it is not necessary to have the domain.xml on the filesystems where other host controllers are running).

When working with a domain we also need to introduce the concept of a server group, which is a set of server instances that will be managed and configured as one. In a managed domain each application server instance is a member of a server group. A domain can have multiple server groups. Different server groups can be configured with different profiles and deployments.

An example domain.xml look as follows:

<domain xmlns="urn:jboss:domain:1.1">
    <extensions>
		<extension module="org.jboss.as.clustering.infinispan"/>
        <extension module="org.jboss.as.clustering.jgroups"/>
		...
        <extension module="org.jboss.as.messaging"/>
		...
        <extension module="org.jboss.as.weld"/>
	</extensions>
    <system-properties>
        <property name="java.net.preferIPv4Stack" value="true"/>
    </system-properties>
    <profiles>
        <profile name="default">
            <subsystem xmlns="urn:jboss:domain:logging:1.1">...</subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
        </profile>
        <profile name="ha">
            <subsystem xmlns="urn:jboss:domain:logging:1.1">...</subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="udp">...</subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
        </profile>
        <profile name="full">
            <subsystem xmlns="urn:jboss:domain:logging:1.1">...</subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:messaging:1.1">...</subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
        </profile>
        <profile name="full-ha">
            <subsystem xmlns="urn:jboss:domain:logging:1.1">...</subsystem>
			...
			<subsystem xmlns="urn:jboss:domain:datasources:1.0">
                <datasources>
                    ...
                    <datasource jta="true" jndi-name="java:/jdbc/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true" use-ccm="true">
                        <connection-url>jdbc:oracle:thin:@192.168.1.65:1521:orcl11</connection-url>
                        <driver>oracle</driver>
                        <pool>
                            <min-pool-size>1</min-pool-size>
                            <max-pool-size>15</max-pool-size>
                            <prefill>true</prefill>
                            <use-strict-min>true</use-strict-min>
                        </pool>
                        <security>
                            <user-name>example</user-name>
                            <password>example</password>
                        </security>
                        <timeout>
                            <idle-timeout-minutes>0</idle-timeout-minutes>
                            <query-timeout>600</query-timeout>
                        </timeout>
                        <statement>
                            <prepared-statement-cache-size>10</prepared-statement-cache-size>
                        </statement>
                    </datasource>
                    <drivers>
					    ...
                        <driver name="oracle" module="com.oracle.database">
                            <driver-class>oracle.jdbc.OracleDriver</driver-class>
                            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                        </driver>
                    </drivers>
                </datasources>
            </subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="udp">...</subsystem>
			...
            <subsystem xmlns="urn:jboss:domain:messaging:1.1">...</subsystem>
			...
			<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
				...
                <connector name="ajp" protocol="AJP/1.3" socket-binding="ajp" enable-lookups="false" max-post-size="1048576" enabled="true" max-connections="150"/>
				...
            </subsystem>
			...
			<subsystem xmlns="urn:jboss:domain:weld:1.0"/>
        </profile>
    </profiles>
    <!--Named interfaces that can be referenced elsewhere in the configuration. The configuration
        for how to associate these logical names with an actual network interface can either
        be specified here or can be declared on a per-host basis in the equivalent element in host.xml.
        These default configurations require the binding specification to be done in host.xml.-->
    <interfaces>
        <interface name="management"/>
        <interface name="public"/>
        <interface name="unsecure"/>
    </interfaces>
    <socket-binding-groups>
        <socket-binding-group name="standard-sockets" default-interface="public">...</socket-binding-group>
        <socket-binding-group name="ha-sockets" default-interface="public">
			...
			<socket-binding name="ajp" port="9080"/>
			...
		</socket-binding-group>
    </socket-binding-groups>
	<deployments>
        <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear">
            <content sha1="161f51dde7f085c822cc4c68b306d57f1bee902d"/>
        </deployment>
    </deployments>
    <server-groups>
        <server-group name="standard-server-group" profile="full">
            <jvm name="default"/>
            <socket-binding-group ref="standard-sockets"/>
        </server-group>
        <server-group name="ha-server-group" profile="full-ha">
            <jvm name="default"/>
            <socket-binding-group ref="ha-sockets"/>
			<deployments>
                <deployment name="LoadTest6.ear" runtime-name="LoadTest6.ear"/>
            </deployments>
        </server-group>
    </server-groups>
</domain>

In the example above we have set-up different profiles:

  • default – a basic server set-up
  • ha – a basic cluster set-up
  • full – a server set-up with messaging enabled
  • full-ha – a cluster set-up with messaging enabled

Different socket-binding groups one for the default and full profiles and one for the ha and full-ha profiles. Further, we defined two server groups, each mapped to a different profile. Note that server groups can have their own settings, such as JVM, socket-binding-group and deployments. To map server instances to a server group, we use a host configuration, for example,

<host name="axis-into-ict.nl" xmlns="urn:jboss:domain:1.1">
    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <authentication>
                    <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
                </authentication>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <properties path="application-users.properties" relative-to="jboss.domain.config.dir" />
                </authentication>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.native.port:9999}"/>
            </native-interface>
            <http-interface security-realm="ManagementRealm">
                <socket interface="management" port="${jboss.management.http.port:9990}"/>
            </http-interface>
        </management-interfaces>
    </management>
    <domain-controller>
       <local/>
       <!-- remote domain controller configuration: remote host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9999}" -->
    </domain-controller>
    <interfaces>
        <interface name="management">
            <nic name="eth0"/>
        </interface>
        <interface name="public">
           <nic name="eth0"/>
        </interface>
        <interface name="unsecure">
            <inet-address value="127.0.0.1"/>
        </interface>
    </interfaces>
    <jvms>
    	<jvm name="default">
            <heap size="512m" max-size="512m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-XX:NewRatio=2"/>
                <option value="-XX:+UseParallelGC"/>
                <option value="-XX:ParallelGCThreads=2"/>
                <option value="-XX:MaxGCPauseMillis=200"/>
                <option value="-XX:GCTimeRatio=19"/>
                <option value="-XX:+UseParallelOldGC"/>
            </jvm-options>
        </jvm>
    </jvms>
    <servers>
        <server name="server1" group="ha-server-group" auto-start="true">
        </server>
        <server name="server2" group="ha-server-group" auto-start="true">
            <socket-bindings port-offset="1"/>
        </server>
    </servers>
</host>

Configuring a host to act as the domain controller is done through the domain-controller declaration in host.xml. If it includes the local element, then this host will become the domain controller. A host acting as the domain controller must expose a native (i.e. non-HTTP) management interface on an address accessible to the other hosts in the domain. Exposing an HTTP management interface is not required, but is recommended as it allows the administration console to work. The configuration above also contains the network interfaces which we mapped to the network interface card eth0.

We can start the domain by using domain.sh located in the ${JBOSS_HOME}/bin directory (do not forget to define JAVA_HOME and PATH before running domain.sh)

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin/
[jboss@axis-into-ict bin]$ ./domain.sh
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/jboss/jboss-as-7.1.0.Final

  JAVA: /home/jboss/jdk1.6.0_31/bin/java

  JAVA_OPTS: -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml

=========================================================================

10:13:12,861 INFO  [org.jboss.modules] (main) JBoss Modules version 1.1.1.GA
10:13:13,459 INFO  [org.jboss.as.process.Host Controller.status] (main) JBAS012017: Starting process 'Host Controller'
[Host Controller] 10:13:14,908 INFO  [org.jboss.modules] (main) JBoss Modules version 1.1.1.GA
[Host Controller] 10:13:15,288 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.2.GA
[Host Controller] 10:13:15,603 INFO  [org.jboss.as] (MSC service thread 1-3) JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
[Host Controller] 10:13:17,216 INFO  [org.xnio] (MSC service thread 1-1) XNIO Version 3.0.3.GA
[Host Controller] 10:13:17,237 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.0.3.GA
[Host Controller] 10:13:17,764 INFO  [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 3.2.2.GA
[Host Controller] 10:13:21,800 INFO  [org.jboss.as] (Controller Boot Thread) JBAS010902: Creating http management service using network interface (management) port (9990) securePort (-1)
[Host Controller] 10:13:21,829 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /192.168.1.66:9999
[Host Controller] 10:13:22,129 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010922: Starting server server1
[Host Controller] 10:13:22,197 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010922: Starting server server2
10:13:22,199 INFO  [org.jboss.as.process.Server:server1.status] (ProcessController-threads - 3) JBAS012017: Starting process 'Server:server1'
[Host Controller] 10:13:22,216 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" (Host Controller) started in 8647ms - Started 11 of 11 services (0 services are passive or on-demand)
10:13:22,292 INFO  [org.jboss.as.process.Server:server2.status] (ProcessController-threads - 3) JBAS012017: Starting process 'Server:server2'
[Server:server1] 10:13:22,976 INFO  [org.jboss.modules] (main) JBoss Modules version 1.1.1.GA
[Server:server2] 10:13:23,121 INFO  [org.jboss.modules] (main) JBoss Modules version 1.1.1.GA
[Server:server1] 10:13:23,671 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.2.GA
[Server:server2] 10:13:23,672 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.2.GA
[Server:server1] 10:13:23,833 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
[Server:server2] 10:13:23,850 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
[Server:server1] 10:13:24,097 INFO  [org.xnio] (MSC service thread 1-3) XNIO Version 3.0.3.GA
[Server:server1] 10:13:24,127 INFO  [org.xnio.nio] (MSC service thread 1-3) XNIO NIO Implementation Version 3.0.3.GA
[Server:server2] 10:13:24,135 INFO  [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.3.GA
[Server:server1] 10:13:24,161 INFO  [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 3.2.2.GA
[Server:server2] 10:13:24,204 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.3.GA
[Server:server2] 10:13:24,236 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 3.2.2.GA
[Server:server1] 10:13:26,666 INFO  [org.jboss.as.logging] (MSC service thread 1-3) JBAS011502: Removing bootstrap log handlers
[Server:server2] 10:13:26,867 INFO  [org.jboss.as.logging] (MSC service thread 1-1) JBAS011502: Removing bootstrap log handlers
[Server:server2] 10:13:26,890 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 32) JBAS015537: Activating WebServices Extension
[Server:server2] 10:13:26,902 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 36) JBAS013101: Activating Security Subsystem
[Server:server2] 10:13:26,993 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 59) JBAS016200: Activating ConfigAdmin Subsystem
[Server:server2] 10:13:26,975 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 55) JBAS010280: Activating Infinispan subsystem.
[Server:server2] 10:13:26,974 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 54) JBAS016300: Activating JacORB Subsystem
[Server:server2] 10:13:26,964 INFO  [org.jboss.as.clustering.jgroups] (ServerService Thread Pool -- 49) JBAS010260: Activating JGroups subsystem.
[Server:server2] 10:13:26,950 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 41) JBAS011940: Activating OSGi Subsystem
[Server:server2] 10:13:26,914 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 42) JBAS011800: Activating Naming Subsystem
[Server:server2] 10:13:27,225 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.6.final
[Server:server2] 10:13:27,568 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
[Server:server2] 10:13:27,719 INFO  [org.jboss.as.connector] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
[Server:server1] 10:13:27,837 INFO  [org.jboss.as.naming] (MSC service thread 1-4) JBAS011802: Starting Naming Service
[Server:server2] 10:13:27,973 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
[Server:server2] 10:13:27,998 INFO  [org.jboss.as.jaxr] (MSC service thread 1-1) Binding JAXR ConnectionFactory: java:jboss/jaxr/ConnectionFactory
[Server:server1] 10:13:27,858 INFO  [org.jboss.as.connector] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
[Server:server2] 10:13:28,163 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
[Server:server1] 10:13:28,187 INFO  [org.jboss.as.jaxr] (MSC service thread 1-4) Binding JAXR ConnectionFactory: java:jboss/jaxr/ConnectionFactory
[Server:server2] 10:13:28,300 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
[Server:server1] 10:13:28,297 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 58) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
[Host Controller] 10:13:28,359 INFO  [org.jboss.as.domain.controller.mgmt] (proxy-threads - 1) JBAS010920: Server [Server:server1] registered using connection [Channel ID 6cdb4665 (inbound) of Remoting connection 71ee88dd to /192.168.1.66:59624]
[Host Controller] 10:13:28,443 INFO  [org.jboss.as.domain.controller.mgmt] (proxy-threads - 1) JBAS010920: Server [Server:server2] registered using connection [Channel ID 025391e5 (inbound) of Remoting connection 633a494d to /192.168.1.66:55081]
[Host Controller] 10:13:28,472 INFO  [org.jboss.as.host.controller] (proxy-threads - 1) JBAS010919: Registering server server1
[Server:server1] 10:13:28,862 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
[Host Controller] 10:13:28,874 INFO  [org.jboss.as.host.controller] (proxy-threads - 2) JBAS010919: Registering server server2
[Server:server2] 10:13:29,228 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
[Server:server1] 10:13:29,225 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
[Server:server1] 10:13:29,387 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
[Server:server2] 10:13:29,449 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 55) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated.
[Server:server2] 10:13:29,672 INFO  [org.apache.coyote.ajp.AjpAprProtocol] (MSC service thread 1-2) Starting Coyote AJP/1.3 on ajp-axis-into-ict.nl-192.168.1.66-9081
[Server:server1] 10:13:29,687 INFO  [org.apache.coyote.ajp.AjpAprProtocol] (MSC service thread 1-1) Starting Coyote AJP/1.3 on ajp-axis-into-ict.nl-192.168.1.66-9080
[Server:server2] 10:13:29,815 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - Stack CXF Server 4.0.1.GA
[Server:server2] 10:13:29,817 INFO  [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http-axis-into-ict.nl-192.168.1.66-8081
[Server:server1] 10:13:29,839 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-3) JBoss Web Services - Stack CXF Server 4.0.1.GA
[Server:server2] 10:13:29,846 INFO  [org.jboss.as.modcluster] (MSC service thread 1-3) JBAS011704: Mod_cluster uses default load balancer provider
[Server:server1] 10:13:29,853 INFO  [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http-axis-into-ict.nl-192.168.1.66-8080
[Server:server1] 10:13:29,879 INFO  [org.jboss.as.modcluster] (MSC service thread 1-2) JBAS011704: Mod_cluster uses default load balancer provider
[Server:server1] 10:13:30,055 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server1/data/messagingjournal,bindingsDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server1/data/messagingbindings,largeMessagesDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server1/data/messaginglargemessages,pagingDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server1/data/messagingpaging)
[Server:server2] 10:13:30,068 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server2/data/messagingjournal,bindingsDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server2/data/messagingbindings,largeMessagesDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server2/data/messaginglargemessages,pagingDirectory=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server2/data/messagingpaging)
[Server:server1] 10:13:30,090 INFO  [org.jboss.modcluster.ModClusterService] (MSC service thread 1-2) Initializing mod_cluster 1.2.0.Final
[Server:server1] 10:13:30,091 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Waiting to obtain live lock
[Server:server2] 10:13:30,102 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) Waiting to obtain live lock
[Server:server2] 10:13:30,131 INFO  [org.jboss.modcluster.ModClusterService] (MSC service thread 1-3) Initializing mod_cluster 1.2.0.Final
[Server:server1] 10:13:30,208 INFO  [org.jboss.modcluster.advertise.impl.AdvertiseListenerImpl] (MSC service thread 1-2) Listening to proxy advertisements on 224.0.1.105:23364
[Server:server2] 10:13:30,264 INFO  [org.jboss.modcluster.advertise.impl.AdvertiseListenerImpl] (MSC service thread 1-3) Listening to proxy advertisements on 224.0.1.105:23364
[Server:server1] 10:13:30,338 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageManager] (MSC service thread 1-3) Using AIO Journal
[Server:server2] 10:13:30,386 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageManager] (MSC service thread 1-2) Using AIO Journal
[Server:server1] 10:13:30,816 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-3) Waiting to obtain live lock
[Server:server1] 10:13:30,817 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-3) Live Server Obtained live lock
[Server:server2] 10:13:30,954 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-2) Waiting to obtain live lock
[Server:server2] 10:13:30,954 INFO  [org.hornetq.core.server.impl.AIOFileLockNodeManager] (MSC service thread 1-2) Live Server Obtained live lock
[Server:server2] 10:13:31,115 INFO  [org.jboss.as.jacorb] (MSC service thread 1-4) JBAS016330: CORBA ORB Service started
[Server:server1] 10:13:31,108 INFO  [org.jboss.as.jacorb] (MSC service thread 1-1) JBAS016330: CORBA ORB Service started
[Server:server1] 10:13:31,341 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
[Server:server2] 10:13:31,438 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
[Server:server2] 10:13:31,439 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:/jdbc/OracleDS]
[Server:server1] 10:13:31,448 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:/jdbc/OracleDS]
[Server:server1] 10:13:31,449 INFO  [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on axis-into-ict.nl/192.168.1.66:4447
[Server:server2] 10:13:31,462 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on axis-into-ict.nl/192.168.1.66:4448
[Server:server2] 10:13:31,554 INFO  [org.jboss.as.jacorb] (MSC service thread 1-4) JBAS016328: CORBA Naming Service started
[Server:server1] 10:13:31,587 INFO  [org.jboss.as.jacorb] (MSC service thread 1-1) JBAS016328: CORBA Naming Service started
[Server:server2] 10:13:32,254 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-2) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5446 for CORE protocol
[Server:server2] 10:13:32,257 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-2) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5456 for CORE protocol
[Server:server1] 10:13:32,257 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-3) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5445 for CORE protocol
[Server:server2] 10:13:32,258 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) Server is now live
[Server:server2] 10:13:32,259 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [2b25644c-61f8-11e1-a2e3-000c2976c82d]) started
[Server:server1] 10:13:32,260 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-3) Started Netty Acceptor version 3.2.5.Final-a96d88c axis-into-ict.nl:5455 for CORE protocol
[Server:server1] 10:13:32,262 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Server is now live
[Server:server1] 10:13:32,263 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [2b200d12-61f8-11e1-9621-000c2976c82d]) started
[Server:server1] 10:13:32,338 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
[Server:server2] 10:13:32,342 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
[Server:server2] 10:13:32,344 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
[Server:server1] 10:13:32,343 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.queue.testQueue
[Server:server2] 10:13:32,347 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) trying to deploy queue jms.queue.testQueue
[Server:server2] 10:13:32,356 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/queue/test
[Server:server2] 10:13:32,362 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
[Server:server2] 10:13:32,368 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-4) trying to deploy queue jms.topic.testTopic
[Server:server1] 10:13:32,368 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/queue/test
[Server:server1] 10:13:32,370 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
[Server:server1] 10:13:32,371 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.topic.testTopic
[Server:server1] 10:13:32,442 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-1) JBAS010406: Registered connection factory java:/JmsXA
[Server:server2] 10:13:32,445 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010406: Registered connection factory java:/JmsXA
[Server:server2] 10:13:32,468 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-2) HornetQ resource adaptor started
[Server:server1] 10:13:32,470 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/topic/test
[Server:server1] 10:13:32,472 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test
[Server:server2] 10:13:32,469 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/topic/test
[Server:server1] 10:13:32,473 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
[Server:server1] 10:13:32,474 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
[Server:server2] 10:13:32,475 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-2) IJ020002: Deployed: file://RaActivatorhornetq-ra
[Server:server2] 10:13:32,478 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test
[Server:server2] 10:13:32,480 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
[Server:server1] 10:13:32,482 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-1) HornetQ resource adaptor started
[Server:server2] 10:13:32,483 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
[Server:server1] 10:13:32,490 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-1) IJ020002: Deployed: file://RaActivatorhornetq-ra
[Server:server1] 10:13:32,497 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
[Server:server2] 10:13:32,504 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 10041ms - Started 169 of 292 services (121 services are passive or on-demand)
[Server:server1] 10:13:32,513 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 10204ms - Started 169 of 292 services (121 services are passive or on-demand)

When starting the domain a process controller is active is as well to start the host controller and the servers. The following shows the process controller log (that is located in the ${JBOSS_HOME}/domain/log directory; in this directory the log file of the host controller is present as well)

10:13:12,861 INFO  [org.jboss.modules] (main) JBoss Modules version 1.1.1.GA
10:13:13,459 INFO  [org.jboss.as.process.Host Controller.status] (main) JBAS012017: Starting process 'Host Controller'
10:13:22,199 INFO  [org.jboss.as.process.Server:server1.status] (ProcessController-threads - 3) JBAS012017: Starting process 'Server:server1'
10:13:22,292 INFO  [org.jboss.as.process.Server:server2.status] (ProcessController-threads - 3) JBAS012017: Starting process 'Server:server2'

In a domain set-up each server automatically gets its own directory, i.e.,

${JBOSS_HOME}/domain
	/configuration
		domain.xml
		host.xml
	/servers
		/server1
			/data
			/log
		/server2
			/data
			/log

Now the question arises: which use cases are appropriate for a domain and which are appropriate for standalone servers? A domain is about coordinated multi-server management, i.e., it offers a central point through which we can manage multiple servers, with the capability to keep the configuration consistent among the servers in a particular server group. The choice between using a domain or standalone server is about how server are managed. As we saw above we can set-up a group of standalone servers to form a cluster. One thing to note here, as we look at the directory structure provided out of the box by using a domain, is that the servers get there own directory structure, i.e., we get data directories that contain among others the HornetQ message bindings and journals and log directories. Recall that in the standalone case, we had to configure this ourselves. So from a management point of view a domain would be the obvious choice when multiple servers are involved.

Once the domain controller is configured we can configure the host controllers that should join the domain. A host controller configuration requires the following steps

  • Define a unique name for the host controller within the domain.
  • Configure the management interface and interface binding on an address that is accessible to the domain controller.
  • Tell the host controller how to find the domain controller so it can register itself with the domain.
  • Define the JVM and the servers to run on the host.

A basic example of a host controller configuration looks as follows:

<host name="hostname" xmlns="urn:jboss:domain:1.0">
	<management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <authentication>
                    <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
                </authentication>
            </security-realm>
        </security-realms>
        <management-interfaces>
            <native-interface security-realm="ManagementRealm">
                <socket interface="management" port="9999"/>
            </native-interface>
        </management-interfaces>
    </management>
	<domain-controller>
       <remote host="hostname or IP-address of the domain controller host" port="9999"/>
    </domain-controller>
    <interfaces>
        <interface name="management">
            <nic name="eth0"/>
        </interface>
    </interfaces>
	<jvms>
    	<jvm name="default">
            <heap size="512m" max-size="512m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-XX:NewRatio=2"/>
                <option value="-XX:+UseParallelGC"/>
                <option value="-XX:ParallelGCThreads=2"/>
                <option value="-XX:MaxGCPauseMillis=200"/>
                <option value="-XX:GCTimeRatio=19"/>
                <option value="-XX:+UseParallelOldGC"/>
            </jvm-options>
        </jvm>
    </jvms>
    <servers>
        <server name="server3" group="ha-server-group" auto-start="true">
			<socket-bindings port-offset="2"/>
        </server>
        <server name="server4" group="ha-server-group" auto-start="true">
            <socket-bindings port-offset="3"/>
        </server>
		<server name="server5" group="ha-server-group" auto-start="true">
            <socket-bindings port-offset="4"/>
        </server>
    </servers>
</host>

Let us deploy the same application to our server-group (ha-server-group). To this end we need to configure a data source for the database. We also want to use the Apache HTTP server for the load balancing, which means we need to configure an AJP connector and socket binding. The domain.xml example presented above already contains the these configurations. From the start-up log we can see that AJP is bound to 192.168.1.66 and listening on ports 9080 for server1 and 9081 for server2. To deploy the application we can use the command-line interface. When doing this we first need to connect to domain controller which is listening on 192.168.1.66:9999 (see log output above)

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin/
[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 192.168.1.66:9999
[domain@192.168.1.66:9999 /] deploy /home/jboss/jboss-as-7.1.0.Final/deploy/LoadTest6.ear --server-groups=ha-server-group

When the application gets deployed the following is observed in the logging

[Host Controller] 10:31:14,061 INFO  [org.jboss.as.repository] (management-handler-threads - 8) JBAS014900: Content added at location /home/jboss/jboss-as-7.1.0.Final/domain/data/content/16/1f51dde7f085c822cc4c68b306d57f1bee902d/content
[Server:server1] 10:31:14,259 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "LoadTest6.ear"
[Server:server2] 10:31:14,262 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "LoadTest6.ear"
[Server:server1] 10:31:14,315 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "Model.jar"
[Server:server2] 10:31:14,315 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "Web.war"
[Server:server2] 10:31:14,316 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "Model.jar"
[Server:server1] 10:31:14,316 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "Web.war"
[Server:server2] 10:31:14,421 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for PersonPersistenceUnit
[Server:server1] 10:31:14,423 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for PersonPersistenceUnit
[Server:server1] 10:31:14,528 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named Company in deployment unit subdeployment "Model.jar" of deployment "LoadTest6.ear" are as follows:
[Server:server1]
[Server:server1]        java:global/LoadTest6/Model/Company!model.logic.Company
[Server:server1]        java:app/Model/Company!model.logic.Company
[Server:server1]        java:module/Company!model.logic.Company
[Server:server1]        java:jboss/exported/LoadTest6/Model/Company!model.logic.Company
[Server:server1]        java:global/LoadTest6/Model/Company
[Server:server1]        java:app/Model/Company
[Server:server1]        java:module/Company
[Server:server1]
[Server:server2] 10:31:14,576 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named Company in deployment unit subdeployment "Model.jar" of deployment "LoadTest6.ear" are as follows:
[Server:server2]
[Server:server2]        java:global/LoadTest6/Model/Company!model.logic.Company
[Server:server2]        java:app/Model/Company!model.logic.Company
[Server:server2]        java:module/Company!model.logic.Company
[Server:server2]        java:jboss/exported/LoadTest6/Model/Company!model.logic.Company
[Server:server2]        java:global/LoadTest6/Model/Company
[Server:server2]        java:app/Model/Company
[Server:server2]        java:module/Company
[Server:server2]
[Server:server2] 10:31:15,167 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011402: Starting Persistence Unit Service 'LoadTest6.ear/Model.jar#PersonPersistenceUnit'
[Server:server1] 10:31:15,182 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011402: Starting Persistence Unit Service 'LoadTest6.ear/Model.jar#PersonPersistenceUnit'
[Server:server2] 10:31:15,377 INFO  [org.jboss.as.ejb3] (MSC service thread 1-1) JBAS014142: Started message driven bean 'CompanyMDB' with 'hornetq-ra' resource adapter
[Server:server1] 10:31:15,381 INFO  [org.jboss.as.ejb3] (MSC service thread 1-4) JBAS014142: Started message driven bean 'CompanyMDB' with 'hornetq-ra' resource adapter
[Server:server2] 10:31:15,558 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /LoadTest6
[Server:server1] 10:31:15,563 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /LoadTest6
[Server:server2] 10:31:15,613 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-4) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
[Server:server1] 10:31:15,613 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-3) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
[Server:server1] 10:31:15,622 INFO  [org.hibernate.Version] (MSC service thread 1-3) HHH000412: Hibernate Core {4.0.1.Final}
[Server:server2] 10:31:15,622 INFO  [org.hibernate.Version] (MSC service thread 1-4) HHH000412: Hibernate Core {4.0.1.Final}
[Server:server1] 10:31:15,624 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH000206: hibernate.properties not found
[Server:server2] 10:31:15,626 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-4) HHH000206: hibernate.properties not found
[Server:server1] 10:31:15,626 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH000021: Bytecode provider name : javassist
[Server:server2] 10:31:15,628 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-4) HHH000021: Bytecode provider name : javassist
[Server:server1] 10:31:15,680 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) HHH000204: Processing PersistenceUnitInfo [
[Server:server1]        name: PersonPersistenceUnit
[Server:server1]        ...]
[Server:server2] 10:31:15,682 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-4) HHH000204: Processing PersistenceUnitInfo [
[Server:server2]        name: PersonPersistenceUnit
[Server:server2]        ...]
[Server:server2] 10:31:15,879 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-4) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
[Server:server1] 10:31:15,882 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-3) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
[Server:server1] 10:31:16,034 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-3) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
[Server:server2] 10:31:16,034 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-4) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
[Server:server2] 10:31:16,052 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-4) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
[Server:server1] 10:31:16,052 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-3) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
[Server:server1] 10:31:16,061 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-3) HHH000397: Using ASTQueryTranslatorFactory
[Server:server2] 10:31:16,062 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-4) HHH000397: Using ASTQueryTranslatorFactory
[Server:server2] 10:31:16,144 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-4) Hibernate Validator 4.2.0.Final
[Server:server1] 10:31:16,145 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-3) Hibernate Validator 4.2.0.Final
[Server:server1] 10:31:17,007 INFO  [org.jboss.as.server] (host-controller-connection-threads - 3) JBAS018559: Deployed "LoadTest6.ear"
[Server:server2] 10:31:17,007 INFO  [org.jboss.as.server] (host-controller-connection-threads - 3) JBAS018559: Deployed "LoadTest6.ear"

As the servers are listening on the same IP addresses and AJP ports as in the standalone case, we do not need to edit anything in the Apache HTTP server configuration. Start the Apache HTTP server and enter the URL: http://hostname:8888/LoadTest6/testservlet and make a few requests to see if everything is working. Open the admin console (http://192.168.1.66:9990/console) and enter the necessary credentials to log in (these we have created in the beginning by using add-user.sh). In the admin console, click server instances and select a particular server. Subsequently, click web to see how many requests were processed by the AJP connector. Let us perform the load test again to see how the environment is performing. When using the jvisualvm we need to know the process IDs of the servers within the domain. To this end we can use the ps command to get information on the running Java process

[jboss@axis-into-ict ~]$ ps -ef|grep java
jboss    7277  7263  0 10:13 pts/2    00:00:06 /home/jboss/jdk1.6.0_31/bin/java -D[Process Controller] -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml -Dorg.jboss.boot.log.file=/home/jboss/jboss-as-7.1.0.Final/domain/log/process-controller.log -Dlogging.configuration=file:/home/jboss/jboss-as-7.1.0.Final/domain/configuration/logging.properties -jar /home/jboss/jboss-as-7.1.0.Final/jboss-modules.jar -mp /home/jboss/jboss-as-7.1.0.Final/modules org.jboss.as.process-controller -jboss-home /home/jboss/jboss-as-7.1.0.Final -jvm /home/jboss/jdk1.6.0_31/bin/java -- -Dorg.jboss.boot.log.file=/home/jboss/jboss-as-7.1.0.Final/domain/log/host-controller.log -Dlogging.configuration=file:/home/jboss/jboss-as-7.1.0.Final/domain/configuration/logging.properties -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml -- -default-jvm /home/jboss/jdk1.6.0_31/bin/java
jboss    7294  7277  0 10:13 pts/2    00:00:11 /home/jboss/jdk1.6.0_31/bin/java -D[Host Controller] -Dorg.jboss.boot.log.file=/home/jboss/jboss-as-7.1.0.Final/domain/log/host-controller.log -Dlogging.configuration=file:/home/jboss/jboss-as-7.1.0.Final/domain/configuration/logging.properties -server -Xms512m -Xmx512m -XX:NewRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml -jar /home/jboss/jboss-as-7.1.0.Final/jboss-modules.jar -mp /home/jboss/jboss-as-7.1.0.Final/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.host-controller --pc-address localhost.localdomain --pc-port 60207 -default-jvm /home/jboss/jdk1.6.0_31/bin/java -Djboss.home.dir=/home/jboss/jboss-as-7.1.0.Final
jboss    7347  7277  9 10:13 pts/2    00:06:43 /home/jboss/jdk1.6.0_31/bin/java -D[Server:server1] -XX:PermSize=256m -XX:MaxPermSize=256m -Xms512m -Xmx512m -server -XX:NewRatio=2 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.rmi.dgc.client.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.awt.headless=true -Djboss.host.default.config=host.xml -D[Host=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.home.dir=/home/jboss/jboss-as-7.1.0.Final -Djboss.domain.default.config=domain.xml -Djava.net.preferIPv4Stack=true -Dorg.jboss.boot.log.file=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server1/log/boot.log -Dlogging.configuration=file:/home/jboss/jboss-as-7.1.0.Final/domain/configuration/logging.properties -jar jboss-modules.jar -mp modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server
jboss    7364  7277  9 10:13 pts/2    00:06:44 /home/jboss/jdk1.6.0_31/bin/java -D[Server:server2] -XX:PermSize=256m -XX:MaxPermSize=256m -Xms512m -Xmx512m -server -XX:NewRatio=2 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=200 -XX:GCTimeRatio=19 -XX:+UseParallelOldGC -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.rmi.dgc.client.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.awt.headless=true -Djboss.host.default.config=host.xml -D[Host=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.home.dir=/home/jboss/jboss-as-7.1.0.Final -Djboss.domain.default.config=domain.xml -Djava.net.preferIPv4Stack=true -Dorg.jboss.boot.log.file=/home/jboss/jboss-as-7.1.0.Final/domain/servers/server2/log/boot.log -Dlogging.configuration=file:/home/jboss/jboss-as-7.1.0.Final/domain/configuration/logging.properties -jar jboss-modules.jar -mp modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server

As we can see the first one (7277) is the process controller; the second (7294) is the host controller; the third (7347) and fourth (7364) are respectively server1 and server2. The load test statistics are as follows

To get request count and processing time information we use the command-line interface

[jboss@axis-into-ict ~]$ cd jboss-as-7.1.0.Final/bin
[jboss@axis-into-ict bin]$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 192.168.1.66:9999
[domain@192.168.1.66:9999 /] cd host=axis-into-ict.nl/server=server1
[domain@192.168.1.66:9999 server=server1] cd deployment=LoadTest6.ear/subdeployment=Web.war/subsystem=web
[domain@192.168.1.66:9999 subsystem=web] cd servlet=TestServlet
[domain@192.168.1.66:9999 servlet=TestServlet] read-attribute request-count
394063
[domain@192.168.1.66:9999 servlet=TestServlet] read-attribute processing-time
930637L
[domain@192.168.1.66:9999 servlet=TestServlet] cd /
[domain@192.168.1.66:9999 /] cd host=axis-into-ict.nl/server=server2
[domain@192.168.1.66:9999 server=server2] cd deployment=LoadTest6.ear/subdeployment=Web.war/subsystem=web
[domain@192.168.1.66:9999 subsystem=web] cd servlet=TestServlet
[domain@192.168.1.66:9999 servlet=TestServlet] read-attribute request-count
394056
[domain@192.168.1.66:9999 servlet=TestServlet] read-attribute processing-time
930302L

To see how the JVMs are doing during the load test we use jvisualvm

The test introduced no particular problems for the JVM.

References

[1] Marchioni, “JBoss AS7 Configuration, Deployment and Administration”, PACKT Publishing, Birmingham, UK, 2011. Essential reading material.
[2] JBoss Documentation.


  • Testimonials

  • RSS Middleware Magic – JBoss

  • Receive FREE Updates


    FREE Email updates of our new posts Enter your email address:



  • Magic Archives

  • Sitemeter Status

  • ClusterMap 7-Nov-2011 till Date

  • ClusterMap 6-Nov-2010 till 7-Nov-2011

  • Copyright © 2010-2012 Middleware Magic. All rights reserved. | Disclaimer