Getting "XmlRootElement cannot be resolved to a type" error after upgrading GWT from 2.8.1 to 2.8.2

In order to fix the broken GWT drag and drop in Chrome 61, we decided to upgrade GWT since the fix is in GWT 2.8.2.

After upgrading, I got hundreds of following errors:

[ERROR] Line 7: XmlRootElement cannot be resolved to a type
[ERROR] Line 3: The import javax.xml.bind cannot be resolved

I tried to upgraded other dependencies to the latest version and got no luck. Any solutions or suggestions are appreciated. Thanks.


Solution 1:

You need to add a dependency on that jar now, it is no longer part of GWT (and probably shouldn't have been to begin with, which is why it is gone):

Maven:

<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.3.0</version>
  <classifier>sources</classifier>
  <scope>provided</scope>
</dependency>

Gradle:

gwt 'javax.xml.bind:jaxb-api:2.3.0'

EDIT: Correction, it looks like this might not be just related to updating GWT, but specific to Java 9 - no longer are these classes included in JDK 9, so you must actually have a dependency on the jaxb-api in your project.

Solution 2:

Using this dependency (added in your POM file) has solved the problem for me

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.1</version>
</dependency>