Question

I'm trying to deploy an existing Jboss 7 war application on the Cloudbees Paas and I'm getting stuck with datasource configuration. Following this dedicated Cloudbees wiki entry and the related thread, I end up with the following error (already mentioned by others in the thread) during application startup :

javax.resource.ResourceException: Wrong driver class [class com.mysql.jdbc.Driver] for this connection URL [jdbc:cloudbees://cbdebate--1]

My configuration files are as follows:

cloudbees-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<cloudbees-web-app xmlns="http://www.cloudbees.com/xml/webapp/1">
 <!-- Application ID (formatted CB_ACCOUNT/APPNAME) -->
 <appid>hck/debate</appid>

 <!-- DataSources (use names refererenced via <resource-ref> in WEB-INF/web.xml) -->
    <resource name="jdbc/debate" auth="Container" type="javax.sql.DataSource">
        <param name="username" value="myuser" />
        <param name="password" value="mypassword" />
        <param name="url" value="jdbc:cloudbees://cbdebate--1" />

        <!-- Connection Pool settings -->
        <param name="maxActive" value="20" />
        <param name="maxIdle" value="2" />
        <param name="maxWait" value="10000" />
        <param name="validationQuery" value="SELECT 1" />
    </resource>
</cloudbees-web-app>

web.xml (relevant part)

(...)
<resource-ref>
    <res-ref-name>jdbc/debate</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>
(...)

persistence.xml (relevant part)

        <persistence-unit name="debate" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/jdbc/debate</jta-data-source>

(... entity classes declaration ...)

        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
            <property name="hibernate.max_fetch_depth" value="5"/>
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
            <property name="org.hibernate.worker.batch_size" value="1000" />
        </properties>
        </persistence-unit>

Thank you in advance for any help

Env : Jboss 7, JPA 2.0

Was it helpful?

Solution

Thanks to Nicolas' answer and some further googling, I managed to get it work. As far as I understand, you cannot use the cloudbees driver com.cloudbees.jdbc.Driver from within a Jboss application (and specifically in our case on Cloudbees Java EE 6 server) and have to use the mysql one com.mysql.jdbc.Driver.
As Nicolas stated the jdbc:cloudbees://[databaseName] database url uses by convention the cloudbees driver. You need to use the url referencing the actual database (you can find it in the cloudbees database configuration page) in the form of :

jdbc:mysql://ec2-AAA-BBB-CCC-DDD.compute-1.amazonaws.com:3306/[databaseName]

the important point here is the jdbc:mysql://...

Change the url of the database in cloudbees-web.xml using the form above and it works !

Maybe the cloudbees people could make the documentation a little bit clearer on this particular point

OTHER TIPS

To use jdbc:cloudbees:* JDBC URL you need to use com.cloudbees.jdbc.Driver as driver class name.

by convention, each jdbc driver registered on a JVM uses a prefix before it's own specific url infos, so that a jdbc URL is "jdbc::"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top