users@jaxb.java.net

IllegalArgumentException (loc parameter must not be null) when try to unmarshall via JAXBResult

From: Matt Magoffin <java.net_at_msqr.us>
Date: Mon, 14 Feb 2005 19:31:01 -0800 (PST)

Hello, I am trying to unmarshall a JAXB object via an XSLT transform. I
have the following code to accomplish this:

Transformer xform = t.newTransformer();
JAXBResult result = new JAXBResult(getUnmarshaller());
xform.transform(new StreamSource(xmlIn),result);

where the getUnmarshaller() method contains

JAXBContext jc = JAXBContext.newInstance(jaxbContext);
Unmarshaller u = jc.createUnmarshaller();
u.setEventHandler(new IgnoreValidation());
u.setValidating(false);
return u;

where basically I do not want to perform validation during unmarshalling
because my input source (the result of the XSLT transform) may contain
validation errors. When I run this, however, I get an
IllegalArgumentException:

Caused by: java.lang.IllegalArgumentException: loc parameter must not be null
        at
javax.xml.bind.helpers.ValidationEventLocatorImpl.<init>(ValidationEventLocatorImpl.java:57)
        at
magoffin.matt.ieat.domain.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:142)

where, looking at my AbstractUnmarshallingEventHandlerImpl.java:142 I see

context.handleEvent( new ValidationEventImpl(
        canRecover? ValidationEvent.ERROR : ValidationEvent.FATAL_ERROR,
        msg,
        new ValidationEventLocatorImpl(context.getLocator()),
        nested ), canRecover );

and context.getLocator() is returning null.

Since I'm unmarshalling from the result of an XSLT transformation,
will/should a Locator exist here? Am I unmarshalling incorrectly?

Thank you for any ideas,
m@