java - interface implemetation in tomcat lib folder not able to refer to interface present in web-inf/classes folder -
i have interface defined in war file under web-inf/classes folder. idea have implementation placed in class path without disturbing war file. solution thought place implementation in tomcat_home/lib directory due possible use of different classloader implementation , interface, interface not getting resolved , classnotfound being thrown. scenario possible achieve?
you getting error because implementation loading in memory before interface because class loaders in application server runtime follow delegation hierarchy classes in tomcat lib loaded before classes in web-inf/classes. if want remove error keep both in tomcat lib, both load @ same time.

in delegation design, class loader delegates classloading parent before attempting load class itself. class loader parent can either system class loader or custom class loader. if parent class loader cannot load class, class loader attempts load class itself. in effect, class loader responsible loading classes not available parent. classes loaded class loader higher in hierarchy cannot refer classes available lower in hierarchy.
Comments
Post a Comment