Friday, June 29, 2007

Deployment Seam Application against MySQL 5 database to Jboss 4.0.5
utilizing Seam Plugin for NetBeans 5.5.1

Attempt of straightforward deployment performed as suggested in Michael Yuan's blog ([2])
for HyperSonic Database causes some issues.View comment # 47 in [2].
Procedure described bellow generates runnable Seam application under Jboss 4.0.5
working with MySQL 5.0.37 database
First of all tune Jboss for proper connection to MySQL datavase as advised in [1].
Install the JDBC driver for JBoss by entering the following:

# cp mysql-connector-java-VERSION.jar $JBOSS_HOME/server/default/lib

Creating a New Data Source
Create a data source binding for a JDBC driver by performing the following on the JBoss Application Server:
Create a data source descriptor file named $JBOSS_HOME/server/default/deploy/mysql-ds.xml
and add the following contents:

<driver-class> com.mysql.jdbc.Driver</driver-class>

Configure the MySQL Server by performing the following steps (unix environment) :
Verify that the MySQL Server is running by entering the following:
# ps -ef|grep mysqld
If the MySQL Server is running, a process named mysqld displays in the output; otherwise, enter the following command:
# /etc/init.d/mysql start
If the database used in the JBoss data source does not exist, create the mytestdb database by entering the following:
# mysqladmin -u root -p create mytestdb
If the database user in the JBoss data source does not exist, create the user and
grant the appropriate privileges by entering the following from the MySQL prompt:
mysql> grant all on mytestdb.* to jboss@'%.%.%.%' identified by \
'jboss'; flush privileges;
The user named jboss with the password jboss is created and granted all operation privileges on the database mytestdb.
To test the connectivity between JBoss and MySQL, perform the following steps on the JBoss Application Server:
Create a JSP file named $JBOSS_HOME/server/default/deploy/jmx-console.war/mysqltest.jsp and add the following contents:

<%@page contentType="text/html" import="*,java.util.*,org.jboss.jmx.adaptor.model.*,*,java.sql.*,javax.sql.*,javax.naming.*"%>
<title>JBoss->MySQL Test </title>
<link rel="stylesheet" href="style_master.css" type="text/css">
<meta http-equiv="cache-control" content="no-cache">
InitialContext ctx = new InitialContext();
DatabaseMetaData dm = null;
DataSource ds = (DataSource)
Connection conn = null;
Statement stmt = null;
try {
conn = ds.getConnection();
dm =conn.getMetaData();
out.println("Connected to-> database version "+dm.getDatabaseProductVersion());
}catch (Exception sqlex) {

Launch JBoss by entering the following:
# $JBOSS_HOME/bin/
Verify that JBoss is connecting to MySQL by opening a browser and navigating to the following URL:

For windows environment manage accordingly.
Create schema in database "mytestdb" to generate Seam project with entities.

Make following changes to generated entities:-

@Table(name = "dba01", catalog = "mytestdb")
replace with
@Table(name = "dba01", catalog = "")

@Table(name = "dba02", catalog = "mytestdb")
replace with
@Table(name = "dba02", catalog = "")

Deploy modified project to Jboss :-

Run deployed Seam Application:-

Jboss output during this run:-