You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Dan Diephouse (JIRA)" <ji...@apache.org> on 2006/12/29 19:48:20 UTC

[jira] Created: (CXF-340) Support adding extra classes to JAXB context

Support adding extra classes to JAXB context
--------------------------------------------

                 Key: CXF-340
                 URL: http://issues.apache.org/jira/browse/CXF-340
             Project: CXF
          Issue Type: Improvement
    Affects Versions: 2.0-M1
            Reporter: Dan Diephouse
             Fix For: 2.0-RC


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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506405 ] 

Freeman Fang commented on CXF-340:
----------------------------------

My last commit get your testcase working.

One thing you need change is you also need inject jaxb.additionalContextClasses into client side.

So your client spring config should be

        <!-- Client Proxy -->
        <jaxws:client id="testClient" address="http://localhost:7081/service/TestService" serviceClass="com.hmsinc.cxftest.service.TestService">
                <jaxws:inInterceptors>
                        <bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
                </jaxws:inInterceptors>
                <jaxws:outInterceptors>
                        <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
                </jaxws:outInterceptors>
            <jaxws:properties>
                        <entry key="jaxb.additionalContextClasses">
                                <bean class="com.hmsinc.cxftest.util.ClassArrayFactoryBean">
                                        <property name="classNames">
                                                <list>
                                                        <value>com.hmsinc.cxftest.model.ExtendedWidget</value>
                                                </list>
                                        </property>
                                </bean>
                        </entry>
        </jaxws:properties>
        </jaxws:client>

Btw, the mock spring container is amazing in your testcase, so I borrow it as a system test to guarantee extra subclass is work for jaxb marshall/unmarshall. :-)
Thanks very much

> 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
>
>         Attachments: cxf-test-extends.tar.gz, cxf-test.tar.gz, Widget.java
>
>
> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506255 ] 

Steve Kondik commented on CXF-340:
----------------------------------

I should add that it's working if you specify the return type on the interface as the extended type,
so I guess this is a polymorphism issue.  The correct XML is making it to the client though.


> 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
>
>         Attachments: cxf-test-extends.tar.gz, cxf-test.tar.gz, Widget.java
>
>
> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506088 ] 

Freeman Fang commented on CXF-340:
----------------------------------

If you want to wrapped mode work, you need specify namespace for Widget property.

something like
       @XmlElement(namespace = "http://cxftest.hmsinc.com/service", required = true) // this annotation is very import for wrapped mode since wrapped mode need match namespace
	public String getName() {
		return name;
	}

The bare mode only compare property name but ignore namespace, that's why your test code can only work with bare mode.

Attachment is the Widget.java after I change

Cheers

> 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
>
>         Attachments: cxf-test.tar.gz
>
>
> 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.


[jira] Assigned: (CXF-340) Support adding extra classes to JAXB context

Posted by "Bozhong Lin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bozhong Lin reassigned CXF-340:
-------------------------------

    Assignee: Freeman Fang

> 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
>         Assigned To: Freeman Fang
>             Fix For: 2.0-RC
>
>
> 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.


[jira] Updated: (CXF-340) Support adding extra classes to JAXB context

Posted by "Dan Diephouse (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Diephouse updated CXF-340:
------------------------------

    Fix Version/s:     (was: 2.0-RC)
                   2.1

Moving these issues to 2.1 as I don't think we'll get them for 2.0. Feel free to switch reschedule if you feel appropriate.

> 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
>         Assigned To: 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.


[jira] Updated: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Kondik updated CXF-340:
-----------------------------

    Attachment: cxf-test-extends.tar.gz

My fault- I thought that the enclosing element set the default namespace.  Inheritance is still not working though.

Attached is an updated version of the test that has an "ExtendedWidget" :)

It fails with the same exception noted above, like JAXB can't see the extended class to use for unmarshalling.



> 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
>
>         Attachments: cxf-test-extends.tar.gz, cxf-test.tar.gz, Widget.java
>
>
> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506550 ] 

Steve Kondik commented on CXF-340:
----------------------------------

It's working great.  Thanks for the help.

> 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
>
>         Attachments: cxf-test-extends.tar.gz, cxf-test.tar.gz, Widget.java
>
>
> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505662 ] 

Freeman Fang commented on CXF-340:
----------------------------------

fixed

Would you please try it again?
Thanks

> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503328 ] 

Freeman Fang commented on CXF-340:
----------------------------------

Hi Steve,

This task is done.

You can add addtional jaxb context class for your server by means of 

        ServerFactoryBean svrBean = new ServerFactoryBean();
        svrBean.setAddress("http://localhost/Hello");
        svrBean.setServiceClass(HelloService.class);
        svrBean.setBus(getBus());

        Map props = svrBean.getProperties();
        if (props == null) {
            props = new HashMap<String, Object>();
        }
        props.put("jaxb.additionalContextClasses", 
                  new Class[] {java.rmi.Remote.class, java.rmi.RemoteException.class});
        svrBean.setProperties(props);
        svrBean.create();


Also almost the same thing on client side

        ClientFactoryBean cfBean = new ClientFactoryBean();
        cfBean.setAddress("http://localhost/Hello");
        cfBean.setBus(getBus());
        cfBean.setServiceClass(HelloService.class);
        Map props = cfBean.getProperties();
        if (props == null) {
            props = new HashMap<String, Object>();
        }
        props.put("jaxb.additionalContextClasses", 
                  new Class[] {java.rmi.Remote.class, java.rmi.RemoteException.class});
        cfBean.setProperties(props);
        Client client = cfBean.create();


> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505687 ] 

Steve Kondik commented on CXF-340:
----------------------------------

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.


[jira] Updated: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Kondik updated CXF-340:
-----------------------------

    Attachment: cxf-test.tar.gz

Here is a simple JAXB/JAXWS/Spring test that illustrates the nulls issue (should this be a separate ticket?)  No inheritance or anything is involved here.

An initial test is performed to be sure that JAXB can marshal/unmarshal and that the objects have equality.  This test passes.

The second test sends a request to a CXF/JAXWS service, but the unmarshalled object has null strings (the long and boolean values are set though).  This test fails.

If you set the ParameterStyle to BARE on the object, the second test will pass.

I can't test the inheritance fixes because my objects aren't unmarshalling properly (but inheritance is definitely failing using BARE with the exception I listed previously).

> 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
>
>         Attachments: cxf-test.tar.gz
>
>
> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505704 ] 

Freeman Fang commented on CXF-340:
----------------------------------

Please append your whole workspace, the server/client code.
Thanks very much

> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12502969 ] 

Steve Kondik commented on CXF-340:
----------------------------------

This is a showstopper for our app, since it doesn't allow for inheritence (JAXB can't see the unreferenced classes).  I'll try to cook up a patch, but I'm new with CXF.

> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503277 ] 

Freeman Fang commented on CXF-340:
----------------------------------

I am working on this issue now, hopefully can add this feature asap


> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12510782 ] 

Daniel Kulp commented on CXF-340:
---------------------------------

Just wanted to update this to let you know I just added support for the jaxb.index file into the jaxb databinding.   Thus, it may work without the "additionalContextClasses"  stuff.



> 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
>
>         Attachments: cxf-test-extends.tar.gz, cxf-test.tar.gz, Widget.java
>
>
> 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.


[jira] Issue Comment Edited: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Freeman Fang updated CXF-340:
-----------------------------

    Attachment: Widget.java

> 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
>
>         Attachments: cxf-test.tar.gz, Widget.java
>
>
> 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.


[jira] Resolved: (CXF-340) Support adding extra classes to JAXB context

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Freeman Fang resolved CXF-340.
------------------------------

    Resolution: Fixed

> 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.


[jira] Commented: (CXF-340) Support adding extra classes to JAXB context

Posted by "Steve Kondik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505365 ] 

Steve Kondik commented on CXF-340:
----------------------------------

The additional classes don't show seem to show up in the generated WSDL.

> 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.