Wednesday, 28 April 2010

Using JAXB annotated classes with GWT and maven

When compiling GWT projects that make use of classes with JAXB annotations it typically works fine within the IDE, as you have the JDK source code available to the compiler. However, running the GWT compiler on the same project from e.g. maven or ant will fail since the JAXB annotations are not part of default java types understood by GWT. In a maven-based GWT project you can fix this by adding the following dependency within your POM file:
<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.2</version>
  <classifier>sources</classifier>
  <scope>provided</scope>
</dependency>