To marshal a long primitive type using JAXB, I have used @XmlJavaTypeAdapter annotation, which will adapt non-String type to a String. Even though it throw erro
class User {
@XmlID
@XmlJavaTypeAdapter(WSLongAdapter.class)
@XmlElement(type=Long.class)
private long id;
// Other variables
// Getter & Setter method
}