users@jaxb.java.net

Re: JAXB - Automatic creation of mandatory children

From: kr vijay <sagivijay_at_yahoo.com>
Date: Tue, 21 Sep 2004 04:36:06 -0700 (PDT)

Hi,

I am doing the following after setting the
validationHandler for both the marshaller and
unmarshaller:

ObjectFactory objectFactory = new ObjectFactory();
ConfigurationMatch configurationMatch =
(ConfigurationMatch)objectFactory.newInstance(com.cisco.paws.ta.ConfigurationMatch.class);

I then add the configurationMatch object to its
parent's list (The parent can contain multiple
configurationMatch elements)

I am then marshalling the root when I get the
following exception. Similarly, I get an exception if
I try to unmarshal an invalid XML. Is this related to
the bug you posted earlier. If so, when is a fix
expected for this. Until then, do I have to manually
create and set the mandatory children?

Thanks a lot,
Vijay

DefaultValidationEventHandler: [ERROR]: a required
field "Name" is missing an ob
ject
     Location: obj:
com.cisco.paws.ta.impl.ConfigurationMatchImpl_at_1682a53
Marshal Exception javax.xml.bind.ValidationException
 - with linked exception:
[com.sun.xml.bind.serializer.AbortSerializationException:
a required field "Name
" is missing an object]

javax.xml.bind.UnmarshalException: Unexpected end of
element {}:configuration_ma
tch
        at
com.cisco.paws.ta.impl.runtime.SAXUnmarshallerHandlerImpl.handleEvent
(SAXUnmarshallerHandlerImpl.java:568)
        at
com.cisco.paws.ta.impl.runtime.AbstractUnmarshallingEventHandlerImpl.
reportError(AbstractUnmarshallingEventHandlerImpl.java:140)
        at
com.cisco.paws.ta.impl.runtime.AbstractUnmarshallingEventHandlerImpl.
reportError(AbstractUnmarshallingEventHandlerImpl.java:137)
        at
com.cisco.paws.ta.impl.runtime.AbstractUnmarshallingEventHandlerImpl.
unexpectedLeaveElement(AbstractUnmarshallingEventHandlerImpl.java:154)
        at
com.cisco.paws.ta.impl.runtime.AbstractUnmarshallingEventHandlerImpl.
leaveElement(AbstractUnmarshallingEventHandlerImpl.java:64)
        at
com.cisco.paws.ta.impl.ConfigurationMatchImpl$Unmarshaller.leaveEleme
nt(ConfigurationMatchImpl.java:214)
        at
com.cisco.paws.ta.impl.runtime.SAXUnmarshallerHandlerImpl.endElement(
SAXUnmarshallerHandlerImpl.java:140)
        at
org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1528)
        at
org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
        at
org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
        at
org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
        at
org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
        at
org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
        at
org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
        at
org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
        at
org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
        at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)

        at
com.cisco.paws.ta.impl.runtime.UnmarshallerImpl.unmarshal(Unmarshalle
rImpl.java:140)
        at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnm
arshallerImpl.java:131)
        at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnm
arshallerImpl.java:178)
        at
com.cisco.paws.ta.RBMLWrapper.unmarshal(RBMLWrapper.java:51)
        at
com.cisco.paws.ta.actions.EditICAction.doDefault(EditICAction.java:51
)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at
java.lang.reflect.Method.invoke(Method.java:324)
        at
com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultAc
tionInvocation.java:302)
        at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
vocation.java:170)
        at
com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(Around
Interceptor.java:35)
        at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
vocation.java:165)
        at
com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(Around
Interceptor.java:35)
        at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
vocation.java:165)
        at
com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(Around
Interceptor.java:35)
        at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
vocation.java:165)
        at
com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(Around
Interceptor.java:35)
        at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
vocation.java:165)
        at
com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.
java:115)
        at
com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(S
ervletDispatcher.java:280)
        at
com.opensymphony.webwork.dispatcher.ServletDispatcher.service(Servlet
Dispatcher.java:250)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
        at com.evermind._csb._prd(.:521)
        at com.evermind._csb._bpc(.:177)
        at com.evermind._ax._ltc(.:668)
        at com.evermind._ax._ubb(.:193)
        at com.evermind._bf.run(.:62)


--- Aleksei Valikov <valikov_at_gmx.net> wrote:

> Hi.
>
> > Is it possible to also unmarshal correctly from an
> > invalid xml (without some of the required
> elements)
> > without an exception being generated if i set a
> > similar validation handler?
>
> Good question. I think, yes, but I've never tried it
> myself. Try setting
> a handler on you unmarshaller an see what will
> happen.
>
> Bye.
> /lexi
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail:
> users-help_at_jaxb.dev.java.net
>
>



                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net