The unmarshaller is created when needed.
//in MicromagData.MicromagMap
byte[] xml;
ByteArrayInputStream bais = new ByteArrayInputStream(xml);
if (unmarshaller==null) unmarshaller = MicromagData.ObjectFactory.createUnmarshaller(true);
if (marshaller==null) marshaller = MicromagData.ObjectFactory.createMarshaller();
Task task = (Task)unmarshaller.unmarshal(bais);
//in class MicromagData.ObjectFactory
public static Unmarshaller createUnmarshaller(boolean validating)
{
try
{
Unmarshaller unmarshaller = new MicromagSchema.ObjectFactory().createUnmarshaller();
unmarshaller.setValidating(validating);
return unmarshaller;
}
catch (JAXBException jaxbe){jaxbe.printStackTrace(); return null; }
In fact if I create the marshaller/unmarshaller ahead of time outside the
j2ee container, and set it as a property of my class running inside the
container at runtime so that (unmarshaller==null) is false, the exception
won't occur. Other exceptions related to classpath or "class definition not found" are all removed this way.
As for the platform dependence of marshaller/unmarshaller, my guess is the
parser was loaded by Thread.currentThread().getContextClassLoader().
Outside the container, the runtime classloader loads an apache sax parser,
but inside the orion container, classloader loads an oracle sax parser.
I expericed similar problem when initializing JAXBContext the standard way
with JaxBContext.newInstance("MicromagSchema").
<Kohsuke.Kawaguchi_at_Sun.COM> wrote:
>How are you invoking the unmarshaller?