users@jaxb.java.net

Re: InstantiationException when unmarshalling fpml instance document

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 17 Apr 2006 16:45:52 -0700

Hunter Stern wrote:
> the java code to unmarshal is:
>
> JAXBContext jc =
> JAXBContext.newInstance("com.riskman.fpml");
>
> Unmarshaller u = jc.createUnmarshaller();
>
> u.setEventHandler(new
> DefaultValidationEventHandler());
>
> u.unmarshal( new FileInputStream(
> "C:\\downloads\\critical\\riskmansite\\hyperjaxbtest\\xml\\ird_ex01_vanilla_swap.xml"
> ) );

That very ird_ex01_vanilla_swap.xml file is in our unit test :-)


> The com.riskman.fpml.DataDocument class is in the
> classpath.
>
> here is the dump from the defaulteventhandler:
>
> DefaultValidationEventHandler: [ERROR]: unrecognized
> type name: DataDocument
> Location: line 7
> javax.xml.bind.UnmarshalException: unrecognized type
> name: DataDocument

I changed the RI so that JAXBContext.toString() would print out the
names of all the classes known to JAXBContext. Can you try that and make
sure DataDocument is in it?

Can you also try the following way of creating JAXBContext?

   JAXBContext.newInstance(ObjectFactory.class,DataDocument.class)

just to be sure? I think ObjectFactory has createDataDocument, so it
should pick things up automatically, but just in case.

And your FpML document starts like this, right?

<FpML
  version="4-0"
  xsi:type="DataDocument"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.fpml.org/2003/FpML-4-0">

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com