JBoss Seam Tracing
 


Summary
In this Insight article I will show how JXInsight 4.0 provides out of the box tracing and profiling for, JBoss Seam, one of the most promising JEE 5 application development frameworks on the market. Our early support for EJB3 and JBoss Seam shows that JXInsight 4.0 offers the most up-to-date performance management solution on the market designed to be used across all phases of the application lifecycle.




Introduction
The example application used is the Seam Booking. This example demonstrates the use of Seam in a Java EE 5 environment. Transaction and persistence context management is handled by the EJB container. The JBoss application server and JBoss Seam framework distribution used where downloaded from here. Both products should be installed and run once before proceeding to ensure that the standard installation and build environment is already correctly configured.


Integration Steps
In the following steps we will integrate a few of the many trace extensions that JXInsight provides. The changes made to the application configuration files where performed in the build environment rather than the post deployment.


Step 1- Integrate JXInsight's JDBC Resource Transaction Analysis Extension [JDBInsight]
Change the book-ds.xml file located in <JBOSS-SEAM-INSTALL-ROOT>/example/booking/


Before
<?xml version="1.0" encoding="UTF-8"?> <datasources>
<local-tx-datasource>
<jndi-name>bookingDatasource</jndi-name>
<connection-url>jdbc:hsqldb:.</connection-url>
<driver-class>org.hsqldb.jdbcDriver</driver-class>
<user-name>sa</user-name>
<password></password>
</local-tx-datasource>
</datasources>

After
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>bookingDatasource</jndi-name>
<connection-url>jdbc:jdbinsight:hsqldb:.</connection-url>
<driver-class>com.jinspired.jdbinsight.drivers.jdbc1x.Driver</driver-class>
<user-name>sa</user-name>
<password></password>
</local-tx-datasource>
</datasources>


Step 2 - Integrate JXInsight's EJB3 Trace Extension
Change the persistence.xml file located in <JBOSS-SEAM-INSTALL-ROOT>/example/booking/resources/META-INF/

Before
<entity-manager>
<name>bookingDatabase</name>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/bookingDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</entity-manager>

After
<entity-manager>
<name>bookingDatabase</name>
<provider>com.jinspired.jxinsight.trace.ext.persistence.PersistenceProvider</provider>
<jta-data-source>java:/bookingDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="jxinsight.persistence.provider" value="org.hibernate.ejb.HibernatePersistence"/>
</properties>
</entity-manager>


Step 3 - Integrate JXInsight Servlet Trace Extension (ServletFilter) OPTIONAL
Insert the following XMl snippet into web.xml file located in <JBOSS-SEAM-INSTALL-ROOT>/example/booking/resources/WEB-INF/

<filter>
  <filter-name>JXInsightFilter</filter-name>
  <filter-class>com.jinspired.jxinsight.trace.ext.servlet.TraceFilter</filter-class>
</filter> <filter-mapping>

<filter-name>JXInsightFilter</filter-name>
  <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>


Step 4 - Rebuild and Redeploy the Seam Booking Application
If the JBoss application server is running please shut it down now. Before building the Seam Booking example application please make sure that the JBoss supplied build and configuration instructions have been performed and tested previously. To rebuild and redeploy the application execute ant at the command line within the <JBOSS-SEAM-INSTALL-ROOT>/example/booking directory. The default ant target is deploy.


Step 5 - Integrate JXInsight's JVMPI Native Agent
Change the run.(bat | sh) file located in <JBOSS-AS-INSTALL-ROOT>/bin

Before
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m

After
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -Xrun"/jxinsight/bin/windows/jdbinsight":g=t


Step 6 - Deploy JXInsight Server and Trace Extension Libraries
The following JXInsight Java Libraries where copied to <JBOSS_AS_INSTALL_ROOT>/server/default/lib

jxinsight-core.jar
jxinsight-ext-j2ee.jar
jxinsight-ext-ejb3.jar
jxinsight-jdbc-drivers.jar


Step 7 - Startup the JBoss Application Server and Seam Booking Web Application
Start the JBoss AS with the run script located <JBOSS_AS_INSTALL_ROOT>/bin. Perform the use cases (login, find hotel, book hotel) within the application to warm up the application creating traces and transaction paths.


Step 8 - The JXInsight Console
Start the JXInsight Management Console. Mount a JXInsight server (monitored JVM process) via the console menu command sequence: File->Mount Server. Enter the host name (localhost) and port number (default 1515). The console should automatically connect and retrieve the metric snapshot. Switch the analysis mode to Profile.

The screenshot below shows a table view within Traces perspective for Servlets, EJB Session Beans, EJB3 EntityManager traced invocations.



The screenshot below shows a table view within Transactions perspective for JDBC resource transactions.



JXInsight will also record Seam annotations in its snapshot model for later investigative with regard to software change and configuration management.




William Louth, JXInsight's Product Architect