I have a program that uses Hibernate and connects to Postgresql over a Unix socket. The program works as expected, but it uses a Java8 runtime environment. I am trying to move it to a Java21 runtime.
With recent JVMs I encountered a problem with a missing method, setCreated() IIRC. Now I am trying to use a newer Unix sockets implementation in the hope of resolving that issue.
One of my most recent attempts uses: org.newsclub.net.unix.socketfactory.AFUNIXSocketFactory and
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>2.10.1</version>
<type>pom</type>
</dependency>
The exception I received is:
2024-12-17 06:12:33 default[20241217t120306] org.postgresql.util.PSQLException: The SocketFactory class provided org.newsclub.net.unix.socketfactory.AFUNIXSocketFactory could not be instantiated. at
org.postgresql.core.SocketFactoryFactory.getSocketFactory(SocketFactoryFactory.java:42) at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:161) at
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at
org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) at
org.postgresql.Driver.makeConnection(Driver.java:458) at
org.postgresql.Driver.connect(Driver.java:260) at
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138) at
com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125) at
com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870) at
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) Caused by: java.lang.ClassNotFoundException: org.newsclub.net.unix.socketfactory.AFUNIXSocketFactory at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at
java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) at
org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:543) at
java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) at
java.base/java.lang.Class.forName0(Native Method) at
java.base/java.lang.Class.forName(Class.java:421) at
java.base/java.lang.Class.forName(Class.java:412) at
org.postgresql.util.ObjectFactory.instantiate(ObjectFactory.java:43) at
org.postgresql.core.SocketFactoryFactory.getSocketFactory(SocketFactoryFactory.java:39) ... 14 more`
Another recent attempt was using com.google.cloud.sql.postgres.SocketFactory. Here the problem I encountered was:
2024-12-17 06:55:39 default[20241217t120306] org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception. at
org.postgresql.Driver.connect(Driver.java:280) at
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138) at
com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125) at
com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870) at
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) Caused by: java.lang.IllegalArgumentException: cloudSqlInstance property not set. Please specify this property in the JDBC URL or the connection Properties with value in form "project:region:instance" at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) at
com.google.cloud.sql.core.InternalConnectorRegistry.connect(InternalConnectorRegistry.java:174) at
com.google.cloud.sql.postgres.SocketFactory.createSocket(SocketFactory.java:81) at
org.postgresql.core.PGStream.<init>(PGStream.java:67) at
org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91) at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192) at
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at
org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) at
org.postgresql.Driver.makeConnection(Driver.java:458) at
org.postgresql.Driver.connect(Driver.java:260) ... 9 more
I am using Hibernate version5.3.7.Final. I am not eager to take on the long overdue Hibernate migration at this moment, but I will if that is required.
I would appreciate guidance as to what SocketFactory implementation and Hibernate version I should be using.
Thank you for your help.