cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Kondik (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CXF-340) Support adding extra classes to JAXB context
Date Mon, 18 Jun 2007 06:34:26 GMT

    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505687
] 

Steve Kondik edited comment on CXF-340 at 6/17/07 11:33 PM:
------------------------------------------------------------

Okay, I see the extra classes in the WSDL, and the SOAP message has the appropriate xsi:type
attributes set now.   I'm still getting an exception on the unmarshal though because it's
still trying to instantiate the abstract class.  I have no problems marshalling/unmarshalling
this object graph with a normal JAXBContext.   (This is with ParameterStyle.BARE, see below).

I'm not sure if this is related or not, but unless I use ParameterStyle.BARE as the SOAPBinding,
most  of the unmarshalled object's values (any object, not just the extended classes) are
null except for a few (unless they are attributes or booleans which seem to work fine).  


Examples without BARE:

This one is OK:

INFO: Inbound Message
--------------------------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getAgeGroupForAgeResponse
xmlns="http://track.hmsinc.com/services"><ns2:agegroup xmlns:ns2="http://track.hmsinc.com/services"
xmlns:ns3="http://www.w3.org/2005/02/addressing/wsdl" maximumAge="64" minimumAge="19" name="Adult"
id="2"/></getAgeGroupForAgeResponse></soap:Body></soap:Envelope>
--------------------------------------
com.hmsinc.track.datamodel.attribute.AgeGroup@10f34cc[id=2,name=Adult,minAge=19,maxAge=64]


But this one is full of nulls:

INFO: Inbound Message
--------------------------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><authenticateUserResponse
xmlns="http://track.hmsinc.com/services"><ns2:trackuser xmlns:ns2="http://track.hmsinc.com/services"
xmlns:ns3="http://www.w3.org/2005/02/addressing/wsdl" id="0"><username>admin</username><password>fAqdF8Fd/25U1nmbkB1JhxfrIpB3Fx4V9OQ/TMjegpt5iFlp9Gp8UpdCiT/FIQ9y</password><emailAddress>root@localhost</emailAddress><firstName>System</firstName><lastName>Administrator</lastName><enabled>true</enabled><roles><role
id="0"><permission>GlobalAdministrator</permission><description>Global
Administrator</description></role></roles></ns2:trackuser></authenticateUserResponse></soap:Body></soap:Envelope>
--------------------------------------
com.hmsinc.track.datamodel.permission.TrackUser@1435ec9[0,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,true,[]]

If there is else anything I can provide to help, just let me know.  I am just using a simple
Spring JAXWS server and client (CXF at both ends). 

This is the exception I get using BARE with abstract classes, but that second example unmarshalls
correctly:

Jun 18, 2007 1:33:59 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error : Unable to create an instance of com.hmsinc.track.datamodel.health.HealthEncounter

        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:251)
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:219)
        at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:40)
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:185)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:399)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1830)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1698)
        at org.apache.cxf.io.CacheAndWriteOutputStream.doClose(CacheAndWriteOutputStream.java:43)
        at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:119)
        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:253)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:204)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
        at $Proxy94.getPatient(Unknown Source)



 was:
Okay, I see the extra classes in the WSDL, and the SOAP message has the appropriate xsi:type
attributes set now.   I'm still getting an exception on the unmarshal though because it's
still trying to instantiate the abstract class.  I have no problems marshalling/unmarshalling
this object graph with a normal JAXBContext.  

I'm not sure if this is related or not, but unless I use ParameterStyle.BARE as the SOAPBinding,
most  of the unmarshalled object's values (any object, not just the extended classes) are
null except for a few (unless they are attributes or booleans which work fine).   However,
without using BARE, the returned object is of the correct type and no exception occurs (but
all of the string fields are null).  

Examples without BARE:

This one is OK:

INFO: Inbound Message
--------------------------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getAgeGroupForAgeResponse
xmlns="http://track.hmsinc.com/services"><ns2:agegroup xmlns:ns2="http://track.hmsinc.com/services"
xmlns:ns3="http://www.w3.org/2005/02/addressing/wsdl" maximumAge="64" minimumAge="19" name="Adult"
id="2"/></getAgeGroupForAgeResponse></soap:Body></soap:Envelope>
--------------------------------------
com.hmsinc.track.datamodel.attribute.AgeGroup@10f34cc[id=2,name=Adult,minAge=19,maxAge=64]


But this one is full of nulls:

INFO: Inbound Message
--------------------------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><authenticateUserResponse
xmlns="http://track.hmsinc.com/services"><ns2:trackuser xmlns:ns2="http://track.hmsinc.com/services"
xmlns:ns3="http://www.w3.org/2005/02/addressing/wsdl" id="0"><username>admin</username><password>fAqdF8Fd/25U1nmbkB1JhxfrIpB3Fx4V9OQ/TMjegpt5iFlp9Gp8UpdCiT/FIQ9y</password><emailAddress>root@localhost</emailAddress><firstName>System</firstName><lastName>Administrator</lastName><enabled>true</enabled><roles><role
id="0"><permission>GlobalAdministrator</permission><description>Global
Administrator</description></role></roles></ns2:trackuser></authenticateUserResponse></soap:Body></soap:Envelope>
--------------------------------------
com.hmsinc.track.datamodel.permission.TrackUser@1435ec9[0,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,true,[]]

If there is else anything I can provide to help, just let me know.  I am just using a simple
Spring JAXWS server and client (CXF at both ends). 

This is the exception I get using BARE with abstract classes, but that second example unmarshalls
correctly:

Jun 18, 2007 1:33:59 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error : Unable to create an instance of com.hmsinc.track.datamodel.health.HealthEncounter

        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:251)
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:219)
        at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:40)
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:185)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:399)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1830)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1698)
        at org.apache.cxf.io.CacheAndWriteOutputStream.doClose(CacheAndWriteOutputStream.java:43)
        at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:119)
        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:253)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:204)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
        at $Proxy94.getPatient(Unknown Source)


> Support adding extra classes to JAXB context
> --------------------------------------------
>
>                 Key: CXF-340
>                 URL: https://issues.apache.org/jira/browse/CXF-340
>             Project: CXF
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Dan Diephouse
>            Assignee: Freeman Fang
>             Fix For: 2.1
>
>
> Users may have their own JAXB classes which need to be included in the context. We should
provide a simple mechanism to add extra classes to the context. (This worked pretty well in
XFire).
> HashMap props = new HashMap();
> props.put("jaxb.additionalContextClasses", new Class[] { Foo.class, Bar.class });
> serverFactory.setProperties(props);
> serverFactory.create();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message