One problem we face when developing applications, especially web applications, is the separation of application and configuration. Application servers help us deal with the problem by exposing JNDI resources that you define in your application server and use in your application. This allows you to have completely different settings from development, testing and production.
By default JBoss AS comes with a database driver for the h2 in-memory database. When you create a new datasource configuration you can only select this driver and it is not apparent where you can add any others, like MySQL.
The solution is as elegant as it is obscure for the novice user. Lets assume you are running JBoss in the Standalone option (standalone.sh or standalone.bat). In the directory structure you will find a folder called deployments. JBoss looks to this folder to find artifacts that it needs to deploy as soon as it starts or if it is already running it will deploy it immediately.
When you drop in the MySQL driver jar into this folder JBoss will activate the driver immediately for you, assuming it is running.
You can verify this by creating a new datasource. You will find the MySQL driver in the list of available drivers.
Although it is not a very obvious place to look to for the installation of drivers, the deployments folder is rather elegant. It allows you to finely tune which drivers are available to your application and allows you to remove unnecessary drivers on each instance.
I did not take a look at how to achieve this in a domain setting. If you have any thoughts on the matter, please leave a comment below.
Image credit: jepoirrier