A possible troubleshooting path is on the scope (provided
) defined for gwt-user
, which is the only library bringing in validation-api
applying the dependencies management above.
Running the following first omitting dropwizard-core
mvn dependency:tree -Dincludes=javax.validation
The output would be:
[INFO] +- com.google.gwt:gwt-user:jar:2.8.0-beta1:provided
[INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | \- javax.validation:validation-api:jar:sources:1.0.0.GA:provided
Taking hence the desired 1.1.0.Final version instead of the transitive 1.0.0.GA one.
(Note the scopes above, the last token per dependency entry, they should all be on provided
because its root, gwt-user
is on provided
scope. However, validation-api
is on compile
because of the dependency management entry).
While omitting gwt-user
the output would be:
[INFO] com.sample:sample2:jar:0.0.1-SNAPSHOT
[INFO] \- io.dropwizard:dropwizard-core:jar:0.9.2:compile
[INFO] \- io.dropwizard:dropwizard-validation:jar:0.9.2:compile
[INFO] \- org.hibernate:hibernate-validator:jar:5.2.2.Final:compile
[INFO] \- javax.validation:validation-api:jar:1.1.0.Final:compile
Hence, indeed, both would bring it in, but the first was defined as provided
scope while the second as default (compile
) scope.
Moreover, the dependency management for validation-api
has been defined for default (compile
) scope, impacting how Maven is bringing it in via gwt-user
(listed above, as compile
, even though gwt-user
is provided
and all of its transitive dependencies would also be on provided
, unless defined differently by dependencies management, like in this case).
Provided dependencies, per official Maven documentation are
available on the compilation and test classpath
Hence you are having during compilation and test two libraries in conjuction, validation-api
and gwt-user
, which would then have different coupling at runtime (gwt-user
is expected to be provided by the runtime container).
If gwt-user
must be in provided
scope, I would suggest to adopt a finer governance and exclude validation-api
directly from gwt-user
. As such, validation-api
will be brought in from dropwizard-core
with the version required by the dependencies management.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.8.0-beta1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Update
From your comment below, you are also using the following as part of your dependencies management:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.8.0-beta1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Which is then also specifying the following in its dependencies management:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<!-- Note: use classifier=sources rather than type=java-sources so they're added to the classpath -->
<classifier>sources</classifier>
</dependency>
While you managed to override the first, you didn't override the second and indeed it is still added to the classpath (check dependency tree output above, the 1.0.0.GA sources are still brought in, in provided scope. That's a further difference between compiler/test and runtime. At runtime, you don't have it as part of your classpath.
I would hence suggest to also add to your dependencies management its 1.1.0.Final version as overriden, so that it would be coherent with the first one.