users@jaxb.java.net

Re: help with unmarshaling

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 23 Jan 2007 12:11:12 -0800

john.mcclain_at_homeq.com wrote:
> Howdy
> I have an EAR project deployed in jboss. The ear file contains an EJB jar
> file, which houses the XJC generated classes in addition to the EJB. The
> ear file also includes 2 war files
> Each war file contains 1 servlet.
>
> The issue is that the servlet from war 1 fails and the servlet from war2
> succeeds, YET THEY ARE COPIES OF EACH OTHER
>
> Here are the datials from a failure/success perspective
>
> servlet from War that SUCCEEDS
> 1)WEB-INF/lib containsa set of jars (call it setx), AND the EJB jar
> containing the XJC generated classes
> 2)the mainfest.mf (classpath) has all the above jars including the EJB
> listed (generated from Maven2) - this means the EJB jar file is in the EAR
> and this wars WEB-INF/lib
> 3) When the servlet runs, i print out the to_string method of the
> jaxbContext, and it shows ALL the specific XJC generated classes except
> for the ObjectFactory
>
> Servlet from WAR that FAILS
> 1)WEB-INF/lib contains ONLY set of jars, setx (see above)
> 2)the mainfest.mf (classpath) has all the above jars including the EJB
> listed (generated from Maven2)
> 3)When the servlet runs, i print out the to_string method of the
> jaxbContext, and it shows ONLY the ObjectFactory generated by XJC

It sounds like a classloader issue. [1] and [2] are relevant docs on
this topic. I suspect you've already looked at [1], but [2] might be
just what you need --- I need to make [1] include [2].

[1] https://jaxb.dev.java.net/guide/Unmarshalling_is_not_working__Help_.html
[2] https://jaxb.dev.java.net/faq/#classloader

Also, Is FIRST_AMERICAN_RESPONSE constant a string? Try passing in
ObjectFactory.class list, as that's the easier way of identifying
classloader problems.

>
> The servlet code FOR BOTH SERVLETS is:
> JAXBContext jaxbContext_tst =
> JAXBContext.newInstance(FIRST_AMERICAN_RESPONSE);
> System.out.println(jaxbContext_tst.toString());
> Unmarshaller unmarshaller_tst =
> jaxbContext_tst.createUnmarshaller();
> unmarshaller_tst.setEventHandler(new
> javax.xml.bind.helpers.DefaultValidationEventHandler());
> RESPONSEGROUP tst = (RESPONSEGROUP)
> unmarshaller_tst.unmarshal(new File(
> "C:\\homeq-maven\\projects\\homeq-bpo\\notes\\resptest.xml" ));
>
> In the success servlet, tst contains all the data, in the failing servlet,
> an unmarshal exception is thrown
>
> The unmarshalexception I get when call unmarshal(...) is:
> 17:08:18,827 INFO [STDOUT] DefaultValidationEventHandler: [FATAL_ERROR]:
> unexpected element (uri:"", local:"RESPONSE_GROUP"). Expected elements are
> (none)
> Location: line 1 of
> file:/C:/homeq-maven/projects/homeq-bpo/notes/resptest.xml
> 17:08:22,093 ERROR [STDERR] javax.xml.bind.UnmarshalException: unexpected
> element (uri:"", local:"RESPONSE_GROUP"). Expected elements are (none)
> 17:08:22,093 ERROR [STDERR] at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(
> UnmarshallingContext.java:556)
> 17:08:22,093 ERROR [STDERR] at
> com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(
> Loader.java:199)
> 17:08:22,093 ERROR [STDERR] at
> com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(
> Loader.java:194)
> 17:08:22,093 ERROR [STDERR] at
> com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(
> Loader.java:71)
> 17:08:22,093 ERROR [STDERR] at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(
> UnmarshallingContext.java:957)
> 17:08:22,108 ERROR [STDERR] at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(
> UnmarshallingContext.java:399)
>
>
> Given that the EAR file contains the EJB jar file containing the XJC
> generated classes, AND the manifest.mf file lists the EJB jar (I believe
> this puts it in the classpath), then why is the failing servlet failing???
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com