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

mustafa commented on CXF-5223:
------------------------------

I should add, this was looked at as part of CXF-4542 but I think in that use 
case we ONLY looked at classes that JAXB already knew about. As soon as you add 
a type that is your own and want a class to be mapped to this it does not 
work... but only in Exception classes. If we add the same thing to a non 
Exception class we get the desired output in the WSDL. In fact, adding it to a 
non exception class causes it to appear in the right place in the Exception 
type in the WSDL!
                
> XMLJavaTypeAdapter not working in Exception Classes
> ---------------------------------------------------
>
>                 Key: CXF-5223
>                 URL: https://issues.apache.org/jira/browse/CXF-5223
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.7.6
>            Reporter: mustafa
>         Attachments: cxfTest.jar
>
>
> @XMLJavaTypeAdapter usage in Exception Classes does not work when mapping to 
> a class not in the JAXB Context.
> {code:title=MyEJB.java}
> @Stateless
> @WebService
> public class MyEJB {
>     public void launcheMyException() throws MyException {
>         return;
>     }
> }
> {code}
> {code:title=MyException.java}
> @XmlAccessorType(XmlAccessType.FIELD)
> public class MyException extends Exception {
>  @XmlJavaTypeAdapter(Cl1ToCl2Adapter.class)
>     MyClass1 obj1;
>     @XmlJavaTypeAdapter(NoArgObjAdapter.class)
>     NoArgObj obj2;
>     public MyClass1 getObj1() {
>               return obj1;
>       }
>     
>     public void setObj1(MyClass1 obj1) {
>               this.obj1 = obj1;
>       }
>       public NoArgObj getObj2() {
>         return obj2;
>     }
>     public void setObj2(NoArgObj obj2) {
>         this.obj2 = obj2;
>     }
> }
> {code}
> {code:title=Cl1ToCl2Adapter.java}
> public class Cl1ToCl2Adapter extends XmlAdapter<MyClass2,MyClass1> {
>     @Override
>       public MyClass2 marshal(MyClass1 v) throws Exception {
>               return new MyClass2();
>       }
>       @Override
>       public MyClass1 unmarshal(MyClass2 v) throws Exception {
>               MyClass1 mc1 = new MyClass1(v.getS2());
>               return mc1;
>       }
> }
> {code}
> This is what the resulting WSDL contains. Obj2 is mapped fine to a String, 
> but MyClass1 is not and should have the MyClass2 mapping here.
> {code:xml}
> <xs:complexType name="MyException">
> <xs:sequence>
> <xs:element name="str" nillable="true" type="xs:string"/>
> <xs:element name="obj2" nillable="true" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> {code}
> If you add the same adapter to a non Exception class it works just fine.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to