How does JVM loads the class when we use one of two options extract or package required libraries while creating runnable jar in eclipse click for details.
Today I ran into an issue, where my main application was using hibernate-core.jar but one of thee jar my main application was depending on was using hibernate-core-5...jar, when this dependent jar was build using 2nd option (package), everything was working properly but when I switched to 1st option to build this jar (extract) I started getting below error.
Caused by: java.lang.ClassCastException: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider cannot be cast to org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
As per SO this happens because of version mismatch and I think its exactly happening with me when I used extract option to build the jar.
My main application uses spring+hibernate(3) but my dependent jar just uses hibernate(5).
What I can interpret from the logs is connectionProvider(hibernate 5) can not be instantiated using LocalDataSourceConnectionProvider (hibernate 3). may be implementation for hibernate 5 is not getting loaded into JVM.
Does packaging .class files or .jar in runnable jar changes the way how classes loaded in JVM?