Expand my Community achievements bar.

SOLVED

CA 5.4 issue: No suitable driver found for jdbc:mysql://localhost:3306/cq

Avatar

Level 1

Hi All,

I am facing an issue in configuring the database connectivity with MySql in CQ5.4. I used this http://helpx.adobe.com/experience-manager/using/datasourcepool.html tutorial for reference.

CQ5.4 is not returning connection object. Its throwing following exception.

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/vic
        at java.sql.DriverManager.getConnection(DriverManager.java:602)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:65)
        at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
        at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)
        at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96)

That's 'com.mysql.jdbc.Driver' class is not loaded into CQ5.4 environment. I am using mysql-connector-java-5.1.14 jar file for connectivity. It is successfully loaded as OSGI bundle.

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

I just tested this and as long as you bundle the driver file in an OSGi fragment-- the DataSourcePool injection works.

[img]AClient.png[/img]

Restart AEM after you deploy everything. 

View solution in original post

2 Replies

Avatar

Level 10

This error means that CQ cannot find the database driver file. Did you follow these steps in the document to place the MySQL connector JAR into CQ (see below).  This file should be in its own bundle fragment and in an Active state. Try restarting CQ as well. 

Add the MySQL driver file to Adobe CQ

 

You have to deploy a bundle fragment to Adobe CQ that contains the database driver file. In this development article, the name of the database driver file is mysql-connector-java-5.1.22-bin. To create an OSGi bundle fragment that contains this database driver file, perform these tasks:

1. Start Eclipse (Indigo). The steps below have been tested on Eclipse Java EE IDE for Web Developers version Indigo Service Release 1.

2. Select File, New, Other.

3. Under the Plug-in Development folder, choose Plug-in from Existing JAR Archives. Name your project jdbcBundle.

4. In the JAR selection dialog, click the Add external button, and browse to the database driver file.

5. Click Next.

6. In the Plug-in Project properties dialog, ensure that you check the checkbox for Analyze library contents and add dependencies.

7. Make sure that the Target Platform is the standard OSGi framework.

8. Ensure the checkboxes for Unzip the JAR archives into the project and Update references to the JAR files are both checked.

9. Click Next, and then Finish.

10. Click the Runtime tab.

11. Make sure that the Exported Packages list is populated.

12. Make sure packages have been added under the Export-Package header in MANIFEST.MF. Remove the version information in the MANIFEST.MF file. Version numbers can cause conflicts when you upload the OSGi bundle to Adobe CQ.

13. Also make sure that the Import-Package header in MANIFEST.MF is also populated.

14. Save the project.

15. Build the OSGi bundle by right-clicking the project in the left pane, choose Export, Plug-in Development, Deployable plug-ins and fragments, and click Next.

16. Select a location for the export (C:\TEMP) and click Finish. (Ignore any error messages).

17. In C:\TEMP\plugins, you should now find the OSGi bundle.

18. Login to Adobe CQ’s Apache Felix Web Console at http://server:port/system/console/bundles (default admin user = admin with password= admin).

19. Sort the bundle list by Id and note the Id of the last bundle.

20. Click the Install/Update button.

21. Check the Start Bundle checkbox.

22. Browse to the bundle JAR file you just built. (C:\TEMP\plugins).

23. Click Install.

24. Click the Refresh Packages button.

25. Check the bundle with the highest Id.

26. Your new bundle should now be listed with the status Active.

27. If the status is not Active, check the CQ error.log for exceptions. If you get “org.osgi.framework.BundleException: Unresolved constraint” errors, check the MANIFEST.MF for strict version requirements which might follow: javax.xml.namespace; version=”3.1.0”

28. If the version requirement causes problems, remove it so that the entry looks like this: javax.xml.namespace.

29. If the entry is not required, remove it entirely.

30. Rebuild the bundle.

31. Delete the previous bundle and deploy the new one.

Avatar

Correct answer by
Level 10

I just tested this and as long as you bundle the driver file in an OSGi fragment-- the DataSourcePool injection works.

[img]AClient.png[/img]

Restart AEM after you deploy everything.