1

I have written custom java ssl factory and not using the default SSL Factory (org.postgresql.ssl.DefaultJavaSSLFactory) while attempting SSL handshake to postgreSQL

jdblUrl = jdbc:postgresql://hostname:port/dbName?sslmode=verify-ca&sslfactory=PathToMyCustomJavaSSLFactory

Custom SSL Factory class is in different jar file and I am trying to use in the main jar file. I am able to successfully use it while calling DB when I run the application locally in my eclipse. But, when I push the main jar to cloud foundry and try to run it, I am getting ClassNotFoundException for the custom SSL factory class. There are other classes in that jar file which I am able to call from main jar. But only for the custom ssl factory it is throwing ClassNotFoundException .

Can someone please help on what I might be missing.

Exception Trace:

{java.lang.ClassNotFoundException: com.cf.commons.db.ssl.CustomJavaSSLFactory","\tat java.net.URLClassLoader.findClass(URLClassLoader.java:449)","\tat java.lang.ClassLoader.loadClass(ClassLoader.java:482)","\tat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:384)","\tat java.lang.ClassLoader.loadClass(ClassLoader.java:415)","\tat java.lang.Class.forName0(Native Method)","\tat java.lang.Class.forNameFW(Class.java:362)","\tat java.lang.Class.forName(Class.java:270)","\tat org.postgresql.util.ObjectFactory.instantiate(ObjectFactory.java:50)","\tat org.postgresql.core.SocketFactoryFactory.getSslSocketFactory(SocketFactoryFactory.java:64)","\t... 77 more"] }

I am using Java 8

sgrgmngt
  • 907
  • 3
  • 12
  • 15

1 Answers1

0

I was able to resolve this issue by including that jar file in the boot loader class path using

-Xbootclasspath/a: 

option. But I didn't like this solution anyway.

P.S, Also, there is another thread in stackoverflow

Shyam Patel
  • 381
  • 2
  • 13
  • Thanks for the response. But as I mentioned above there are other classes in that jar which works fine, but only for Custom SSL factory, I am getting this issue? – sgrgmngt Oct 12 '22 at 06:53