users@jaxb.java.net

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

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 16 Feb 2005 13:13:39 -0800

Matt Magoffin wrote:
> 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?

What XSLT engine are you using? A well-behaving XSLT engine should set a
Locator object to JAXB, so that the above context.getLocator() won't
return null. That's a contract defined by the SAX API.

So if you change it to another XSLT engine, you might be able to make it
work.

You can also work around the issue by calling getContentHandler from
JAXBResult and invoke setDocumentLocator with maybe new
org.xml.sax.helper(s).LocatorImpl().

I'll fix the code so that the JAXB RI works more gracefully with those
broken SAX event sources.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com