Thursday, August 21, 2008


Deployment Seam 2.0.2 Application against Oracle 10gR2 database to Jboss 4.2.3 via NetBeans 6.1 on Solaris Nevada (b96)



Technical exercise bellow is targeting testing Jboss-Seam 2.0.2 SP1 with
NetBeans 6.1 (JDK 6.0) to deploy Brian Leonard's Sample to Jboss 4.2.3
on Solaris Nevada ( build 96) with xVM kernel.
Hibernate has been selected as persistence provider. Oracle 10gR2 database instance has been installed on SNV93 DomU for performance evaluation.

Oracle 10g installation procedure on Solaris Nevada DomU may be viewed if needed



To tune Jboss 4.2.3 instance and make it connects to Oracle Server, perform the following steps on the JBoss Application Server 4.2.3 :
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://localhost:8080/jmx-console/oracleTest.jsp








Follow [1],[2] in new environment.
Add corresponding jars to ejb and web modules ([2]) and
proceed with persistence.xml , keeping Hibernate as persistence provider and selecting datasource as


java:/OracleDS


previously defined for Jboss 4.2.3 Server.








Proceed with tuning web.xml,ejb-jar.xml,faces-config.xml per [1].














Modify code of entity bean User.java and RegistrationActionBean.java ([1])
to instantiate Seam instances at runtime and delete JSF managed bean
as no longer needed.Right click in text area to run "Fix imports" and
select appropriate ones. Embedding seam annotations will require this
fixes to be done.








Annotation @Interceptors({org.jboss.seam.ejb.SeamInterceptor.class})
is required only if ejb-jar.xml has not been modified.
Otherwise , it is not needed








Deploy "Registration Application" to Jboss and run.











Connect to Oracle database from NetBeans 6.1 and perform query against table "users" cumulating inserted records.








Jboss status via NetBeans 6.1 may be viewed here.











Regarding "Seam Plugin for NetBeans 6.1" , please , view [3],[4].
Viewing comments in [3] requires login, otherwise feedbacks stay hidden.
References
1.http://weblogs.java.net/blog/bleonard/archive/2007/06/seam_refresh_1.html
2.http://weblogs.java.net/blog/caroljmcdonald/archive/2008/01/sample_applicat_4.html
3.http://davidsalter.co.uk/index.php?q=node/104
4.http://seamframework.org/Community/SeamgenNetbeansPlugin