users@jersey.java.net

Null pointer exception in jaxb unmarshalling

From: Erdinc Yilmazel <erdinc_at_yilmazel.com>
Date: Thu, 12 Mar 2009 19:10:51 +0000

Well I'm not sure if this is the right place to post this message, but
here it goes.
I am getting a null pointer exception while jersey client tries to
unmarshall the returned xml from the web service.
This exception occurs on com.sun.xml.bind.v2.runtime.reflect.Lister
class on the following method.

        public void addToPack(T collection, Object o) {
            collection.add(o);
        }

The collection propert is null in my case.

The bean that is causing the trouble is something like this:

@XmlRootElement(name = "xxx")
public class RegistryEntryDetails {
    ...
   @XmlElement(name = "registryEntry")
   public RegistryEntry getRegistryEntry() {
   }

   @XmlElementWrapper(name = "units")
   @XmlElement(name = "unit")
   public ArrayList<Unit> getUnits() {
   }
}

Both RegistryEntry and Unit classes are simple java classes
(containing only simple types of attributes like primitives and
string) both annotated with XmlRootElement.

On the server side there is no problem, it can marshall this object as
expected. (One resource method returning an instance of
RegistryEntryDetails). However the client side does not work.

Any ideas?

Thank you,
Erdinc