Yes, I'm asking the same question so thanks for writing up an example. BTW, I agree we can't just look at everything in a classloader... was only thinking that if we had an xsi:type in the incoming message, we could look for ObjectFactory or .packageInfo in the corresponding package. This only works if you use the dflt TNS->pkg mapping though.
On Fri, Sep 12, 2008 at 1:02 PM, Raymond Feng <[EMAIL PROTECTED]> wrote: > Let's put Tuscany on the side for a moment and look at the following pure > JAXWS/JAXB case: > > In the XSD, we use XML inheritance to model Address as the base type, > USAddress and UKAddress as the subtypes. Then we generate the JAXWS/JAXB > classes using a tool. Now we have a JAXWS method like: > > int shipTo(Address address); // USAddress and UKAddress can be passed > in for the address > > How do people create JAXBContext in this case? What if USAddress and > UKAddress are from different packages? > > BTW, I'm not sure how we can scan the java classes on the classpath. Maybe > it works for URLClassLoader but not for all cases. > > Thanks, > Raymond > > From: Scott Kurz > Sent: Friday, September 12, 2008 9:43 AM > > To: [email protected] > Subject: Re: JAXBException > > > Could we (in theory at least), on the XML->JAXB path, look at the xsi:type, > and see if we can find anything in the classloader to match it that we > haven't already registered with the JAXBContext, and then make a new > JAXBContext including the subclass package if necessary? > > Maybe we could cache the new context (though this might mean doing a > synchronize{} somewhere). > > This is all starting to sound pretty expensive... is this a valuable > enough use case?... I wonder what other web service implementations do with > this issue? > > Scott > > > > On Wed, Sep 10, 2008 at 1:10 PM, Raymond Feng <[EMAIL PROTECTED]> wrote: > > Let's assume java.lang.Object maps to xsd:anyType. Maybe we can check the > object to see if it is a subclass of the parameter type. If the subclass is > not part of the JAXBContext, then we create a new JAXBContext to include it. > It might help the transformation from JAXB to XML (I expect to see a > xsi:type for the subtype such as xsi:type="foo:FooType"). But we cannot > handle the XML to JAXB path because we don't know the subclass for the JAXB > object. IIRC, the XML will be unmarshalled into the base type and the > properties in the subtype lost. > > Thanks, > Raymond > > From: Scott Kurz > Sent: Wednesday, September 10, 2008 6:53 AM > To: [email protected] > Subject: Re: JAXBException > > > > Dave, > > The issue is that we look at the interface to determine what types to > register with the JAXBContext. Your interface only shows java.lang.Object > as the input type... and though > com.example.jms.JMSPOJO extends Object, the JAXBContext was not set up to > know about this type. > > I was wondering myself what to do about this issue... and also what, say, > the Axis2 runtime does in this situation. > > Scott > > > > On Wed, Sep 10, 2008 at 9:28 AM, Dave Sowerby <[EMAIL PROTECTED]> > wrote: > > Hey guys, > > I'm encountering a problem in the serialization of Objects when using > binding.jms and a method signature of: > > public String sayHello(Object obj); > > Basically, I pass a POJO and on the client side during transformation > for transport, I get the below stack... > > It looks like the class in question hasn't been registered with the > JAXBContext - can anyone give me any pointers here, I'm concerned I'm > doing something obviously silly! > > Cheers, > > Dave. > > org.apache.tuscany.sca.databinding.TransformationException: > javax.xml.bind.MarshalException - with linked exception: > [javax.xml.bind.JAXBException: class com.example.jms.JMSPOJO nor any > of its super class is known to this context.] > at > org.apache.tuscany.sca.databinding.jaxb.JAXB2Node.transform(JAXB2Node.java:52) > at > org.apache.tuscany.sca.databinding.jaxb.JAXB2Node.transform(JAXB2Node.java:36) > at > org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:199) > at > org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl..java:81) > at > org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformertransform(Input2InputTransformer.java:247) > at > org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformertransform(Input2InputTransformer.java:45) > at > org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl..java:81) > at > org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:186) > at > org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:76) > at > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:287) > at > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:154) > at $Proxy9.sayHello(Unknown Source) > > -- > Dave Sowerby MEng MBCS >
