Java Class Loader Trace

My webapplication throws the following ClassCastException:

java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4ResultSetMetaData cannot be cast to org.postgresql.jdbc4.Jdbc4ResultSetMetaData 

Obviously the classes are the same, so this is a strange mistake.

I found out using the -verbose:class that the Jdbc4ResultSetMetaData class Jdbc4ResultSetMetaData loaded from two jar files, one from my Jetty lib / ext / directory and from the / WEB -INF / lib directory in my web application. These jar files are exactly the same version (md5sum are identical)

This makes me think that this is indeed the same class, but a ClassCastException can be thrown by two different class loaders loading the same class.

Is it possible to register / track the name or identifier of a class loader that loads classes using the jvm parameter?

+6
source share

Source: https://habr.com/ru/post/1013980/


All Articles