views:

187

answers:

3

I wanted to use the JaxB annotation in my class like this:

@XmlRootElement
public class ItemExtension implements Serializable {

But GWT complains when I put it in the client side.

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

Is there a workaround or am I doing something wrong?

A: 

You might find a viable solution here: GWT with JPA

Stijn Van Bael
+3  A: 

I have a project that uses entity classes with both JPA and JAXB annotations in the client-side GWT code. See the section "Overriding one package implementation with another" in the GWT Documentation.

Let's say your module is in package com.example.app. You will need to recreate[1] all JAXB annotation classes in a new package, specifically com.example.app.jre.java.xml.bind.annotation; in your module XML file, you then add <super-source path="jre" /> and you're set.

Note that you don't need to distribute the class files in that package, they are needed solely for the sake of the GWT compiler.

[1]: You can copy them over and adjust all package references.

Tassos Bassoukos