Closed abg closed 1 year ago
Yes, that will need to be updated. The buildpack is presently looking for JARs matching mariadb-java-client*.jar
or mysql-connector-java*.jar
. https://github.com/cloudfoundry/java-buildpack/blob/9ffb37f9fb643a1edf48b8abdc79941ded046abf/lib/java_buildpack/framework/maria_db_jdbc.rb#L49
Hello!
I could reproduce it with the latest spring-music
(based on SB3).
Another way to notice the misuse of the Maria DB connector, is via the actuator:
GET http://app.com/actuator/env
[...]
{
"name": "cfenvjdbc",
"properties": {
"spring.datasource.url": {
"value": "jdbc:mysql://mysql.service.internal:3306/service_instance_db?user=xxx&password=yyy&sslMode=VERIFY_IDENTITY&useSSL=true&requireSSL=true&enabledTLSProtocols=TLSv1.2&serverSslCert=/etc/ssl/certs/ca-certificates.crt"
},
"spring.datasource.username": {
"value": "xxx"
},
"spring.datasource.password": {
"value": "yyy"
},
"spring.datasource.driver-class-name": {
"value": "org.mariadb.jdbc.Driver"
}
}
}
[...]
if indeed we use an older mysql-connector-java
connector, we'll get the expected usage:
{
"name": "cfenvjdbc",
"properties": {
"spring.datasource.url": {
"value": "jdbc:mysql://mysql.service.internal:3306/service_instance_db?user=xxx&password=yyy&sslMode=VERIFY_IDENTITY&useSSL=true&requireSSL=true&enabledTLSProtocols=TLSv1.2&serverSslCert=/etc/ssl/certs/ca-certificates.crt"
},
"spring.datasource.username": {
"value": "xxx"
},
"spring.datasource.password": {
"value": "yyy"
},
"spring.datasource.driver-class-name": {
"value": "com.mysql.cj.jdbc.Driver"
}
}
}
My team maintains a MySQL broker for TAS. In our test pipelines, we deploy a couple different Spring based apps to test JDBC bindings. One of these apps is built exclusively with the Oracle MySQL Connector/j. In a recent dependency bump, we noticed that the app was using the MariaDB v2.7.9 connector rather than MySQL connector bundled in the app. This seems to occur after we bumped to MySQL Connector/j v8.0.31+.
We discovered that Oracle recently renamed the Maven coordinates from
mysql-connector-java
tomysql-connector-j
, this in turn changed the file naming convention frommysql-connector-java-$VERSION.jar
tomysql-connector-j-$VERSION.jar
. This applies to MySQL Connector/j 8.0.31+, even when using the legacymysql:mysql-connector-java
reference. We think this naming change may have broken some assumptions in java-buildpacks MariaDB JDBC FrameworkReproduction steps:
Clone spring-music
Build the app
./gradlew assemble
Observe that the app is built with mysql-connector-j-8.0.33 (e.g. by inspecting
unzip -l build/libs/spring-music-1.0.jar | grep -E 'maria|mysql'
or similar)Push the app
Bind the app to a MySQL service
Start the app
Observe that java-buildpack downloads the MariaDB JDBC connector, even though a MySQL connector is present.
Under the hood, on the MySQL database we can also see that the app is incorrectly using the MariaDB connector provided by the buildpack: