I don't think that this will work consistent for several implementations. It depends on the classloader behaviour.
A chance might be to have the fourth party lib need to be extracted from the war and packed in a surrounding EAR or you create a module and set a dependency. In that case the third party lib inside the war will have priority.
That will work reliable in any container I think.