JAXB and XML Binding prior to 4.0 provide the deprecated Validator class. This class is unavailable in XML Binding 4.0 as on-demand validation is no longer supported.
It is instead recommended to use Schema Validation to perform unmarshal-time validation.
Here is an example of how to use Schema Validation:
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema dataObjectSchema = schemaFactory.newSchema(newFile("dataObjectSchema.xml"));
jaxbUnmarshaller.setSchema(dataObjectSchema);
See the Jakarta EE 9.1 documentation for more information about this removed class.