August 13, 2012

How to install MySQL DataSource on JBoss EAP 6 and AS 7.

The interior of the JBoss EAP 6 and the community version JBoss AS 7, which EAP version is based on, has changed a lot in the latest version. In this blog I will walk you through how to install a MySQL DataSource, and by doing that I will touch two important differences with the new version of JBoss.
  • The changed classloading to a more OSGI like architecture.
  • The simplification of have only one configuration file.
First we will create a new module. A module in this sense is a package of classes that will be available to all our application through your JBoss node. This is a big differences compared with older JBoss version where all deployed archive where directly available to other deployed application when deployed in the deployment root folder.

You find module in $JBOSS_HOME/modules folder. To create a new module you need to do three things:
  1. Create a folder hierarchy for files.
  2. Copy module jar files.
  3. Create module configuration file – module.xml.
Now edit the module.xml file: Now you are ready to use configure your DataSource. Here I will use the JBoss Standalone and not the Domain configuration. In short the main differences between Module and Standalone JBoss configuration is if you want to reuse your configuration through several JBoss instance you shoud use the Domain configuration approach. In this blog I will use the Standalone configuration, but the differences of doing the other way around is not big.

The configuration of the JBoss can be done in several way: 1. CLI 2. Web interface 3. or manually through editing xml file. Which way you choose is up to you, here I will show the result.



Pablo Rodriguez said...

Good post, thx 4 the example

Anonymous said...

It's Awesome. Thanks so much :)

Anonymous said...

I was so close to give up with Java and use .net instead. Thanks!

Japhe said...

Hi, thanks for your blog. However I think there is a typo when you are distinguishing between domain and standalone, the work should be "domain" in the sentence "In short the main differences between **Module** and Standalone JBoss..." Thanks.

Anonymous said...

Thank you very much for this sample. I did find, however, that it didn't work unless I modified the section in the standalone.xml file to look like this:


Without the element JBoss wouldn't add the datasource stating that dependencies were not being met.

Is it possible that one your system the dependency for the was declared somewhere else?

Also, without the element, JBoss also complained that loading the "mysql" driver was a duplicate attempt to load the driver and threw an exception about it.

Any chance you can elaborate further to help us understand why your sample didn't work in my JBoss EAP 6.3 environment without the addition of the element.


Anonymous said...

Thank you! It's helped me.