Re: Proper way to add a MySQL datasource to JOnAS ?

Benoit Pelletier <[email protected]> Wed, 16 Mar 2011 11:26:22 +0100
Newsgroups gmane.comp.java.objectweb.jonas
Organization BULL SAS
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 ?&
>   
you might create a deployment plan with 2 resources to ensure the 
loading sequence  : 1) the driver 2) the ds
The resources have to be located in a dedicated repository (url) defined 
in $JONAS_BASE/conf/initial-repository.xml

Regards;
> Regards,
> Frederic Dang Tran
> Orange Labs
>
>
>
>
>   


-- 

----------------------------------------------------------------
Benoit Pelletier
http://jonas.ow2.org
Bull, Architect of an Open World TM
http://www.bull.com