Search code examples
javajakarta-eejarwartomcat8

What will happen if [WEB-INF/lib] and [tomcat/lib] contain similar JARs?


Today I was asked in an interview, what will happen at the time of deployment if the Tomcat's lib and your WEB-INF/lib of the war file contains same jar file?

I tested today in my machine, I didn't found any difference. Application is deploying successfully.

I have gone through with this similar article , For, more clarification if anyone is having idea about what will happen if the Tomcat's lib and WEB-INF/lib contains same jar what will happen ??


Solution

  • the jar contained in your WEB-INF/lib will be picked up by tomcat. The only caveat is core container jar's will be loaded in preference to jar's in WEB-INF/lib.

    read : https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html#Class_Loader_Definitions