JDK: 1.8.0_131
Tomcat: 8.0.27.0
Hibernate Validator: 6.0.7.Final + all the dependencies downloaded from: Hibernate Validator 6
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public AccountSyncResponse excute(AccountSyncRequest account_sync_request_)
{
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<AccountSyncRequest>> violations = validator.validate(account_sync_request_);
.
.
.
.
AccountSyncResponse _AccountSyncResponse = new AccountSyncResponse();
return _AccountSyncResponse;
}
The code fail on Validation.buildDefaultValidatorFactory()
with the exception:
java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;
at org.hibernate.validator.internal.xml.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63)
at org.hibernate.validator.internal.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:527)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:328)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
It looks like the wrong jar file is being used but I can’t figure out which one.
I had this same issue after upgrading from Springboot 1.5.x to Springboot2. The solution was to upgrade Java EE 7 to Java EE 8:
From:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
To:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>