I'm trying to connect to postgres using the JDBC c...
# troubleshooting
m
I'm trying to connect to postgres using the JDBC connector. I've added the
flink-connector-jdbc:3.3.0-1.20
jar into the deployment runtime under
/opt/flink/lib/ext/…
but I get this error when trying to run a job using the connector:
Copy code
[…]
Caused by: org.apache.flink.table.api.ValidationException: Multiple factories for identifier 'jdbc' that implement 'org.apache.flink.table.factories.CatalogFactory' found in the classpath.

Ambiguous factory classes are:

org.apache.flink.connector.jdbc.catalog.factory.JdbcCatalogFactory
org.apache.flink.connector.jdbc.core.database.catalog.factory.JdbcCatalogFactory
	at org.apache.flink.table.factories.FactoryUtil.discoverFactory(FactoryUtil.java:639) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.factories.FactoryUtil.getCatalogFactory(FactoryUtil.java:802) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.factories.FactoryUtil.createCatalog(FactoryUtil.java:499) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.catalog.CatalogManager.initCatalog(CatalogManager.java:376) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.catalog.CatalogManager.createCatalog(CatalogManager.java:330) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.operations.ddl.CreateCatalogOperation.execute(CreateCatalogOperation.java:88) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:1102) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:735) ~[flink-table-api-java-uber-1.20.1.jar:1.20.1]
	at com.pagero.owl.flink.datagen.main$package$.main(main.scala:23) ~[?:?]
	at com.pagero.owl.flink.datagen.main.main(main.scala:13) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
	at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:356) ~[flink-dist-1.20.1.jar:1.20.1]
	... 7 more
2025-05-05 10:06:25,220 ERROR org.apache.flink.runtime.webmonitor.handlers.JarRunHandler   [] - Exception occurred in REST handler: Could not execute application.
Is it not possible to install the connector directly on the server? It's working with other dependencies…
I tried removing the dependency from the
/opt/flink/lib/ext
directory and add them to my job assembly, and it gives the same error. Am I doing something weird? 🤔
p
If the same error happened, it means you probably already have this dependency duplicated somewhere. Check all directories Flink uses on its path.
m
I think it was a use-case issue rather than anything; I tried defining a CATALOG using the JDBC connector but I'm now thinking this is me misunderstanding the use-case. My hope was to be able to select tables freely from Postgresql without defining them in the session using
CREATE TABLE
but I was mistaken. The classloading issue is not there when I simply use
CREATE TABLE x (…) WITH ('connector' = 'jdbc', …)
Thanks for replying though 😅