With JBoss 6.0.0.M1 out to try out the new JSRs the following may be helpful in reducing time to deploy.
The usual way in which we deploy an application (war , jar or ear ) is to drop the application archive ( or in expanded mode with the folder name ending with .war or .ear) under deploy folder of the server.
But how to deploy an application archive or a folder when it is not residing under deploy folder but resides in some other external folder?
Let’s say the application ROOT folder is E:\javaapps\myapptodeploy\webapplication.war, then in jboss-service.xml (under conf folder of the JBoss server profile (like default, all)), we mention the following. This is very helpful when we build the project using Maven as we can mention the target directory directly without copying the files after each build.
<attribute name="URLs">
deploy/,file:///E:/javaapps/myapptodeploy
</attribute>
MySQL connections in a pool times out after a long period of inactivity [I believe 8 hours is the time period by default.] Hence the connections in the pool become stale and this results in exceptions like java.sql.SQLException: Communication link failure.(The same scenario can also be simulated by bringing JBoss up when MySQL is up and running and then restarting MySQL server.) To avoid this we have to instruct JBoss to validate a connection by issuing a test SQL.
Option 1 and the preferred way to do it is to place the following in the datasource configuration file for JBoss
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE datasources
PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
"http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<datasources>
<local-tx-datasource>
<jndi-name>TestDB</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/seam</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>password</password>
<min-pool-size>4</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>10</idle-timeout-minutes>
<exception-sorter-class-name>
com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter
</exception-sorter-class-name>
<valid-connection-checker-class-name>
com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
</valid-connection-checker-class-name>
<background-validation>true</background-validation>
<background-validation-minutes>10</background-validation-minutes>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Option 2 - We can also validate the connection by using the following.
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<new-connection-sql>select 1</new-connection-sql>
JBoss documentation suggests Option 1 is the preferred way.