Re: Re: Proper way to add a MySQL datasource to JOnAS ?
Frederic Dang Tran <[email protected]> Wed, 16 Mar 2011 13:52:57 +0100
| Newsgroups | gmane.comp.java.objectweb.jonas |
|---|---|
| Message-ID | <[email protected]> |
On Mar 16, 2011, at 11:26 AM, Benoit Pelletier wrote: > >> 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 Sure I can do that but it seems to me to be a bit heavyweight: turning a datasource xml file into a maven artifact, redeploying it on a maven rep each time I tweak one of its settings... It would be nice if the user has some level of control on the order with which items in the $JONAS_BASE/deploy directory are deployed. Maybe something similar to the way services are started on Linux (S01,S02...). For example, let's assume I have two unrelated JavaEE applications each with its own deployment plan dp1.xml and dp2.xml. These 2 applications requires MySQL configured with a deployment plan db.xml. I copy db.xml, dp1.xml, dp2.xml into $JONAS_BASE/deploy. How can I make sure that db.xml is deployed first ? Regards, F.