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:



<datasources>
<local-tx-datasource>
<jndi-name>MysqlDS</jndi-name>
<connection-url>
jdbc:mysql://localhost:3306/mytestdb
</connection-url>
<driver-class> com.mysql.jdbc.Driver</driver-class>
<user-name>jboss</user-name>
<password>jboss</password>
<max-pool-size>50</max-pool-size>
<min-pool-size>20</min-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements>true</track-statements>
</local-tx-datasource>
</datasources>




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.net.*,java.util.*,org.jboss.jmx.adaptor.model.*,
java.io.*,java.sql.*,javax.sql.*,javax.naming.*"%>
<html>
<head>
<title>JBoss->MySQL Test </title>
<link rel="stylesheet" href="style_master.css" type="text/css">
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<%
InitialContext ctx = new InitialContext();
DatabaseMetaData dm = null;
DataSource ds = (DataSource)
ctx.lookup("java:/MysqlDS");
Connection conn = null;
Statement stmt = null;
try {
conn = ds.getConnection();
dm =conn.getMetaData();
out.println("Connected to-> database version "+dm.getDatabaseProductVersion());
}catch (Exception sqlex) {
out.println(sqlex.getMessage());
}finally{
conn.close();
}
%>
</body>
</html>




Launch JBoss by entering the following:
# $JBOSS_HOME/bin/run.sh
Verify that JBoss is connecting to MySQL by opening a browser and navigating to the following URL:
http://localhost:8080/jmx-console/mysqltest.jsp


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




Make following changes to generated entities:-



In Dba01.java
@Entity
@Table(name = "dba01", catalog = "mytestdb")
replace with
@Entity
@Table(name = "dba01", catalog = "")


In Dba02.java
@Entity
@Table(name = "dba02", catalog = "mytestdb")
replace with
@Entity
@Table(name = "dba02", catalog = "")






Deploy modified project to Jboss :-




Run deployed Seam Application:-





Jboss output during this run:-




References.
1.http://docs.hp.com/en/5991-5569/ar01s04.html?btnNext=next%A0%BB
2.http://www.michaelyuan.com/blog/2007/04/17/first-release-of-seam-plugin-for-netbeans/

Saturday, June 23, 2007


Deployment Seam Application against Oracle 10g database to Jboss 4.0.5
utilizing Seam Plugin for NetBeans 5.5.1 on CentOS 5.0



To tune Jboss 4.0.5 instance as advised in [1] and make it connects to Oracle Server, perform the following steps on the JBoss Application Server:
Download the JDBC driver for Oracle 10g Release 2 located at:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
For the Oracle JDBC driver with JDK 1.4 and 1.5, use the ojdbc14.jar file.
Copy the JDBC driver to the JBoss environment by entering the following:
# cp ojdbc14.jar $JBOSS_HOME/server/default/lib
Create a file named $JBOSS_HOME/server/default/deploy/oracle-ds.xml and add the following contents:



<datasources>
<local-tx-datasource>
<jndi-name>oracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@IP_OR_HOSTNAME_OF _ORACLE_DB_ SERVER:1521:ORACLE_SID
</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>USERNAME</user-name>
<password>PASSWORD</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>




Testing the Oracle Database Connectivity
Test the connectivity between JBoss and Oracle by performing the following steps on the JBoss Application Server:
Create a JSP file named $JBOSS_HOME/server/default/deploy/jmx-console.war/oracleTest.jsp and add the following contents:



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




Start JBoss by entering the following:
# $JBOSS_HOME/bin/run.sh
Verify that the Oracle test page is displayed by opening a browser and navigating to the following URL:
http://YOUR_HOSTNAME:8080/jmx-console/oracleTest.jsp




JDK version has been used 1.5.09. You might experience problems with 1.6.01.


Install Seam Plugin [2] and facelets support for NetBeans 5.5.1.
Register Jboss 4.0.5 instance with NetBeans and proceed following [2]












Unload NetBeans IDE, restart Jboss to make sure application run stable.








References.
1.http://docs.hp.com/en/5991-5569/ar01s04.html?btnNext=next%A0%BB
2.http://www.michaelyuan.com/blog/2007/04/17/first-release-of-seam-plugin-for-netbeans/

Monday, June 11, 2007


Learning Marty Hall's JSF Tutorial with Jboss IDE for Eclipse and Exadel Studio Pro



The most current version of Exadel Studio Pro is an extended trial version
that can be used until Exadel Studio Pro becomes open source under JBoss:
(1) 4.0.4a (Last update: May 4, 2007)
(2) Eclipse version required: Eclipse 3.2.1
(3) Expiration Date: August 30, 2007



Downloading and Installing Exadel Studio Pro.



Download the appropriate installation file for your platform from www.exadel.com/web/portal/download
Unzip the file.Create a text file called com.exadel.studio.link in the links folder within the Eclipse IDE for Jboss 2.0.0 home folder.The content of the file should be point to the place where you unzipped Exadel Studio:
path=<ExadelStudioHome>
for example: path=c:/ExadelStudioPro. (Always use forward slashes.)
Start Eclipse with -clean option: eclipse -clean
Note, that you cannot import samples from [1] directly into Eclipse IDE for Jboss.
View [1] for details.
Define Jboss 4.0.5 Server within IDE:-






Import original applications:-







Add listener to web.xml:-





Deployment to Jboss 4.0.5 :-







Runtime snapshots:-









Just a reminder,follow this way you will be using only open source software,
avoiding any charges connected with MyEclipse 5.5 GA until early fall,
when Red Hat Developer Studio (former Exadel Studio Pro) will become available.


References
1.http://www.coreservlets.com/JSF-Tutorial/eclipse-projects.html

Sunday, June 10, 2007


Running Marty Hall's JSF Tutorial samples with Exadel Studio Pro 4.0.4a



The most current version of Exadel Studio Pro is an extended trial version
that can be used until Exadel Studio Pro becomes open source under JBoss:
(1) 4.0.4a (Last update: May 4, 2007)
(2) Eclipse version required: Eclipse 3.2.1
(3) Expiration Date: August 30, 2007



Downloading and Installing Exadel Studio Pro.



Download the appropriate installation file for your platform from www.exadel.com/web/portal/download
Unzip the file.Create a text file called com.exadel.studio.link in the links folder within the Eclipse home folder.The content of the file should be point to the place where you unzipped Exadel Studio:
path="ExadelStudioHome"
for example: path=c:/ExadelStudioPro. (Always use forward slashes.)
Start Eclipse with -clean option: eclipse -clean


Note, that you cannot import samples from [1] directly into Eclipse 3.2.X.
Purchase of MyEclipse Plugin subscription seems to be quite necessary.
View [1] for details.
TomCat 5.5.23, installed as Windows service, has been used for JSF Web Application deployment. Samples have been previously imported into Exadel Studio Pro 4.0.4a .
Regarding deployment to Jboss 4.0.5 , view also:-
Learning Marty Hall's JSF Tutorial with Jboss IDE for Eclipse and Exadel Studio Pro
Proceed as follows, utilizing Exadel Studio Plugin import into Eclipse:-

















Just a reminder,follow this way you will be using only open source software,
avoiding any charges connected with MyEclipse 5.5 GA until early fall,
when Red Hat Developer Studio (former Exadel Studio Pro) will become available.


References.
1.http://www.coreservlets.com/JSF-Tutorial/eclipse-projects.html