Identifying the problem

The implementation class ApacheValidationProvider implements the interface ValidationProvider that is visible at the level of the server/lib class loader. That implementation class cannot see the version of ValidationProvider at the level of the WAR WEB-INF/lib. The two interfaces exist on different class loaders so they are not equivalent.

When the program tries to cast the implementation class ApacheValidationProvider at the server/lib level to the interface ValidationProvider at the WEB-INF/lib classloader, the result is ClassCastException.