• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Servlet container - duplicate class definition

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
do you know if I can count on any predictible behaviour of a servlet container if I have a duplicate class definition in the classpath (for example the same class packaged in two different JARs in /WEB-INF/lib)?
Is that kind of situation addressed anywhere in the servlet specification? Or perhaps in the general JVM (classloader) specification?
 
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing the Servlet Spec regarding this. Don't do it.
 
author & internet detective
Posts: 40169
812
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. And I've seen unpredictable behavior. Well, it is predictable in that "it depends on which code is loaded first." But that's not something one can rely on.
 
Tomasz Szymanski
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I meant, Jeanne - I was wondering whether you can rely on any particular class loading order. And thus - if it's theoretically possible to "patch" a web application without replacing an old JAR, but by adding a new one, which would kind of override the old one. But from what you both said - it isn't. Thanks, both of you.
 
Bear Bibeault
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. it isn't.

You like Russian Roulette?
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Would loading the Class in Parent class loader help in such cases?
Based on the principle - "If webapp class loader needs some class it would check if Parent has one and if it is not there then it will try to load it from WEB-INF\lib or WEB-INF\classes".

 
Bear Bibeault
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I repeat, you like Russian Roulette?
 
Jeanne Boyarsky
author & internet detective
Posts: 40169
812
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And once the class is loaded, it is even worse. You have some classes referring to one version and others pointing to another. Bear is correct. Abandon this idea!
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic