Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting Cloud Run to Cloud SQL. #42581

Open
gunjanthesystem opened this issue Aug 16, 2024 · 4 comments
Open

Error connecting Cloud Run to Cloud SQL. #42581

gunjanthesystem opened this issue Aug 16, 2024 · 4 comments

Comments

@gunjanthesystem
Copy link

gunjanthesystem commented Aug 16, 2024

Still getting similar error as #24743 . Followed: https://quarkus.io/guides/deploying-to-google-cloud#using-cloud-sql-with-a-jdbc-driver . Please suggest. Using non reactive jdbc approach.

Error:

Caused by: org.postgresql.util.PSQLException: The SocketFactory class provided com.google.cloud.sql.postgres.SocketFactory could not be instantiated.
at org.postgresql.core.SocketFactoryFactory.getSocketFactory(SocketFactoryFactory.java:43)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:231)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:273)
at org.postgresql.Driver.makeConnection(Driver.java:446)
at org.postgresql.Driver.connect(Driver.java:298)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:225)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:580)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:561)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.google.cloud.sql.postgres.SocketFactory
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 io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:117)
at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:67)
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:50)
at org.postgresql.core.SocketFactoryFactory.getSocketFactory(SocketFactoryFactory.java:39)
... 13 more

Exception in thread "Shutdown thread" java.lang.NullPointerException: Cannot invoke "io.quarkus.runtime.Application.isStarted()" because "app" is null
at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:455)

application.properties is:

quarkus.datasource.jdbc.url=jdbc:postgresql:///my_db
quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=my-gcp-project:us-west4:my-postgres-instance
quarkus.datasource.jdbc.additional-jdbc-properties.socketFactory=com.google.cloud.sql.postgres.SocketFactory

build.gradle is:

dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation enforcedPlatform("${quarkusPlatformGroupId}:quarkus-google-cloud-services-bom:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-rest'
implementation 'io.quarkus:quarkus-hibernate-orm-panache'
implementation 'io.quarkus:quarkus-jdbc-postgresql'
implementation 'io.quarkus:quarkus-hibernate-orm'
implementation 'com.google.cloud.sql:postgres-socket-factory:1.15.2'
}

quarkusPluginVersion=3.13.2

Originally posted by @gunjanthesystem in #24743 (comment)

@gsmet
Copy link
Member

gsmet commented Aug 16, 2024

Is it in native mode?

@gunjanthesystem
Copy link
Author

No, not native mode, using jvm mode

Copy link

quarkus-bot bot commented Aug 27, 2024

/cc @loicmathieu (google-cloud)

@loicmathieu
Copy link
Contributor

@gunjanthesystem can you provide a reproducer project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants