Proper way to add a MySQL datasource to JOnAS ?

Frederic Dang Tran <[email protected]> Wed, 16 Mar 2011 11:10:30 +0100
Newsgroups gmane.comp.java.objectweb.jonas
Message-ID <[email protected]>
Hi:

So far I've added a MySQL datasource to JOnAS (5.2.0M5) the old way:
-by adding the JDBC driver jar file  (mysql-connector-java-5.1.11-bin.jar)  in $JONAS_BASE/lib/ext  
-by activating the dbm service and adding the datasource in jonas.properties

jonas.services   ...,dbm,...
jonas.service.dbm.datasources   MySQL

I understand that the proper way to do that in JOnAS is now:
-to turn the driver jar file into an OSGi bundle (e.g. with Bnd) and put it in $JONAS_BASE/deploy
-to add an xml datasource file in  $JONAS_BASE/deploy:

mysql-ds.xml:

<datasources xmlns="http://jonas.ow2.org/ns/datasource/1.0">
    <datasource>
        <datasource-configuration>
            <name>foobar</name>
            <url>jdbc:mysql://localhost:3306/foobar</url>
            <classname>org.gjt.mm.mysql.Driver</classname>
  ...
</datasources>

With this config, I get this exception when starting JOnAS:

JOnASResourceService.__deployRar : Error when deploying the rar file: .../work/deployer/datasources/jonas/ds-foobar-8710787520291361920.rarError processing Rar: Class Name not found:org.gjt.mm.mysql.Driver: javax.resource.ResourceException: Class Name not found:org.gjt.mm.mysql.Driver
org.ow2.jonas.resource.ResourceServiceException : Error processing Rar: Class Name not found:org.gjt.mm.mysql.Driver: javax.resource.ResourceException: Class Name not found:org.gjt.mm.mysql.Driver
	at org.ow2.jonas.resource.internal.JOnASResourceService.__createRA(JOnASResourceService.java:472)

because the MySQL datasource is set up before the driver bundle is loaded (?)

How to fix that ?

Regards,
Frederic Dang Tran
Orange Labs