Jboss Deploy Jdbc Driver Maven



With the 7.0.1 release of AS7 comes a new release of the JBoss AS7 Maven Plugin. In addition to allowing you to deploy your apps to AS7, the plugin now has the ability to automatically add datasources to a running AS7 instance.

Microsoft

Deploying a datasource is a two stage process, first we have to deploy the driver, then we setup a datasource through the AS7 management api. The example below walks you through the process of deploying a postgresql datasource, but for the impatient among you a complete example can be found here.

Maven

To deploy a database driver we first have to list our driver in the <dependencies> section of pom.xml:

If you're using a driver different from the one supplied with JasperReports Server, you should have already downloaded a JDBC driver jar for your database type. (See Working With JDBC Drivers, if you have not yet done this.) You need to make an explicit reference to your JDBC driver file name so that JBoss EAP/Wildfly will know the exact file name. Dear all, I'm trying to set up an EAR project from Netbeans, using the wildfly-maven-plugin (1.0.2-Final) in a maven project. I'm able to upload the mysql connector as a jdbc driver, and I can create a datasource manually based on it. Install JDBC drivers on JBoss Installing JDBC Drivers JDBC Driver is what enables Java applications to talk to specific RDBMS, such as MySQL, DB2, Oracle, etc. Download the JDBC Driver from the database vendor (for MySQL go to http://www.mysql.com/products/connector).

We then have to setup the JBoss AS7 Maven plugin to deploy the datasource to the app server:

Jboss Deploy Jdbc Driver Maven Dependency

Oracle jdbc driver maven

Running mvn package will now connect to a running AS7 instance on localhost and deploy the driver as a deployment named postgresql.jar.

Jboss Deploy Jdbc Driver Maven

Note that this capability it not limited to just deploying database drivers, using the deploy-artifact goal it is possible to deploy any maven artifact to the app server.

Now that we have our driver deployed, we need to create the DataSource. To do this, we will need to update our pom again so it looks like this:

With this configuration running mvn install should deploy a Postgresql datasource to AS7.

For some more examples, including XA DataSource and MySQL examples, please see my example pom.xml at https://github.com/stuartwdouglas/quickstart/blob/master/datasource/pom.xml.

You may have noticed about that the name of the maven goal is add-resource, rather than add-datasource. This is because the plugin is not limited to just adding datasources, but can also be used to add other resources to AS7. Internally the plugin uses the AS7 management API, and the <address> and <properties> elements correspond exactly to the management API / command line equivalents. This means that we can add other resources as well, e.g. JMS Queues.

Jboss Deploy Jdbc Driver Maven Installer

The first thing we need to do is figure out the syntax we need to use to add a JMS Queue. To do this we are going to use the command line client. Fire up an instance of AS7, and then in another terminal window run jboss-admin.sh in the bin directory. You should see the following:

Jboss deploy jdbc driver maven tutorial

Type connect and you should connect to the running AS7 instance. Now we need to figure out the syntax to add a JMS Queue. To do this we run the following command:

This should give us the following result:

Maven Jdbc Driver

This output means that the operation has three parameters, entries, selector and durable, Of type List, String, and Boolean respectively. Using this information we can add queue on the command line as follows:

Now lets re-create this from the maven plugin:

The most interesting part of the above configuration is the <entries> element. Because the parameter is of a non-primitive type (in this case LIST), it must be specified as a DMR String. The !! escape as the start of the test tells the plugin to interpret it as such.