Subject: [pgjdbc/pgjdbc] issue #2112: Single argument version of Class.forName is used to load classes, which can cause problems with non-flat class paths

From: "stuartwdouglas (@stuartwdouglas)" <[email-masked]>
Date: Mon, 29 Mar 2021 10:34:11 +0000

**Describe the issue**
Some code in the driver uses `Class.forName(String)` rather than `Class.forName(String, boolean, ClassLoader)` passing in the Thread context class loader as a parameter. This can cause issues for environments where the class being loaded is not in the same ClassLoader as the driver.

**Driver Version?** 

42.2.19

**To Reproduce**

We have an issue in Quarkus here: https://github.com/quarkusio/quarkus/issues/15782

Basically the SocketFactory is loaded from the same CL as the driver, while in our environment it is availilble in the Thread context ClassLoader.

**Expected behaviour**

The class to be loaded from the Thread context CL, possibly with a fallback to  the driver CL.

---

From: "jhonnyman (@jhonnyman)" <[email-masked]>
Date: Fri, 24 Feb 2023 12:12:34 +0000

Hello, I am recently developing applications on Quarkus framework and facing the exact same issue. Is there a possibility to unlock this fix? Thank you :pray:

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Fri, 24 Feb 2023 12:18:13 +0000

@jhonnyman what version of the driver are you using ?

---

From: "jhonnyman (@jhonnyman)" <[email-masked]>
Date: Fri, 24 Feb 2023 12:25:51 +0000

I'm not sure which version it is.
I was following the guides on Quarkus [deploying-to-google-cloud](https://quarkus.io/guides/deploying-to-google-cloud#using-cloud-sql) and using the recommended configuration I got the error that brought me here [Unable to use Postgres Socket Factory on dev mode](https://github.com/quarkusio/quarkus/issues/15782).

Maybe  @stuartwdouglas can you help here? I'm on quarkus version 2.16.1.Final

---

From: "mikhail-chystsiakou (@mikhail-chystsiakou)" <[email-masked]>
Date: Thu, 13 Jul 2023 20:16:23 +0000

Hi people, +1 unhappy developer here (also from quarkus project)

I created minimal project to reproduce the issue, hope it will help you
https://github.com/mikhail-chystsiakou/pgjdbc-15782

Driver version is `org.postgresql:postgresql:42.6.0`

@davecramer , can you please take a look?

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Mon, 24 Jul 2023 15:27:57 +0000

I think we have discussed this before. 
The challenge isn't in fixing it, the challenge here is understanding what it will break.

---

From: "stuartwdouglas (@stuartwdouglas)" <[email-masked]>
Date: Sun, 05 May 2024 23:42:41 +0000

Re-visiting this would you be open to a fix that allows this behaviour to be controlled by a config property of some kind (e.g. a system property, or some other form of config)?

Personally I don't believe that my PR will break anything, as any environment that has set the TCCL would be expecting it to be used, and the fallback means it will continue to work in environments where it is not set, but if this is a concern then I think a config option is the only way to fix this.

---

From: "geoand (@geoand)" <[email-masked]>
Date: Mon, 23 Jun 2025 10:58:57 +0000

+1