users@jersey.java.net

[Jersey] java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to

From: Brendan cheng <ccp999_at_hotmail.com>
Date: Wed, 14 Dec 2011 09:57:08 +0000

Hi,
I received an error:
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to hk.itags.core.Log
from jersey client
public interface hk.itags.core.Log {
    Date getDate();
    String getAuthorName();
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class hk.itags.core.neo4j.restclient.Log implements hk.itags.core.Log {
        @XmlAttribute(required = true)
        Date createdDate;
        @XmlElement(required = true)
        String authorName;


        public Log() {
        } public Date getCreatedDate() {
                return this.createdDate;
        }

        public String getAuthorName() {
                return authorName;
        }}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso({ hk.itags.core.neo4j.restclient.Log.class })
public class Person {
        
        @XmlElementWrapper
        @XmlAnyElement
        public List<Log> logs = null;


        public Person() {
        }

        public Person(Date updatedDate) {
                logs = new ArrayList<Log>();
                logs.add(new hk.itags.core.neo4j.restclient.Log(234, updatedDate, "Peter", "ABC", "234", "4556",
                                "Manager", PersonLogType.NameChange, "TYTT"));
                logs.add(new hk.itags.core.neo4j.restclient.Log(245, updatedDate, "Peter", "ABC", "234", "4556",
                                "Manager", PersonLogType.NameChange, "TYTT"));
        }// client side construction}
from my resource file
        @GET
        @Produces({ "application/xml", "application/json" })
        public hk.itags.core.neo4j.restclient.Person getStartup(){
                        return new hk.itags.core.neo4j.restclient.Person(new Date(System.currentTimeMillis()));
                return null;
        }my client call like this:
hk.itags.core.neo4j.restclient.Person person = hk.itags.gui.Client.service.path("Person").accept(MediaType.APPLICATION_XML_TYPE).get(hk.itags.core.neo4j.restclient.Person.class);
                                
How can I avoid the cast exception in this case?
Brendan