Search code examples
gwtmavenrequestfactory

GWT RequestFactory with maven


I was trying to run a request factory example, but, I got this error running a mvn clean install.

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/carlos/workspace/requestfactory/tutorial/src/main/java/cleancodematters/requestfactory/tutorial/client/Tutorial.java:[74,53] cannot access javax.validation.ConstraintViolation
class file for javax.validation.ConstraintViolation not found
    context.save( pizza ).fire( new Receiver<Void>() {
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/home/carlos/workspace/requestfactory/tutorial/src/main/java/cleancodematters/requestfactory/tutorial/client/Tutorial.java:[74,53] cannot access javax.validation.ConstraintViolation
class file for javax.validation.ConstraintViolation not found
    context.save( pizza ).fire( new Receiver<Void>() {

The code of the example can be found at github. I tried other examples, tried to change the pom.xml, I think I tried almost everything, and I always jump in the same error.

Thanks in advance.


Solution

  • I would assume the problem is related to the following dependencies:

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <classifier>sources</classifier>
      <scope>test</scope>
    </dependency>
    

    In the first dependency you are using a classifier "sources" which does not make sense at all. Furthermore the scope "test" does not make sense either, cause these classes are needed for compilation etc. So you should use no scope. Just reduce it to the following single dependency:

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
    </dependency>
    

    A second point is why are you using the build-helper-plugin and add a supplemental folder which is not necessary, cause it's already added by the maven-processor-plugin based on the documentation. And it would be wise to update the maven-war-plugin to the most-up-to-date (2.2)