What happens when you have the same class twice in a war deployed to tomcat?

What happens if you have the same compiled class twice in a war deployed to tomcat? (I know this is not good practice, and so on, but what happens behind the scenes?)
Are there any chances of unpleasant side effects?

+4
source share
2 answers

I would expect the behavior to be the same as anywhere else.

The first class found by the class loader will be used, the other will be ignored.

+2
source

If you have one class in WEB-INF / classes and another in the bank, then in WEB-INF / classes there will be priority.

, , . , , .

, , , , . - WAR, , .

, , , JHades. , WAR:

java -jar jhades-standalone-report.jar path/to/war/webapp.war

>>>> Jar overlap report:

poi-3.5-FINAL-20090928.jar overlaps with poi-3.7-20101029.jar - total overlapping classes: 990
xercesImpl-2.7.0.jar overlaps with xercesImpl-2.9.1.jar - total overlapping classes: 867
xalan-2.6.0.jar overlaps with xalan-2.7.1.jar - total overlapping classes: 711
bcel-5.2.jar overlaps with xalan-2.7.1.jar - total overlapping classes: 361
xml-apis-2.9.1.jar overlaps with xml-apis.jar - total overlapping classes: 301
jasperreports-applet-3.7.1.jar overlaps with jasperreports-javaflow-3.7.1.jar - total overlapping classes: 254
jasperreports-3.7.1.jar overlaps with jasperreports-applet-3.7.1.jar - total overlapping classes: 254
...

Total number of classes with more than one version: 6169
+4

All Articles