cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-6821) XMLJavaTypeAdapter not working in Exception Classes
Date Fri, 04 Mar 2016 10:03:40 GMT

     [ https://issues.apache.org/jira/browse/CXF-6821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Marco updated CXF-6821:
-----------------------
    Description: 
@XMLJavaTypeAdapter usage in Exception Classes does not work when mapping to a list of objects
not in the JAXB Context.

MyEJB.java
<div class="code panel" style="border-width: 1px;">
@Stateless
@WebService
public class MyEJB {

    public void launcheMyException() throws MyException {
        return;
    }
}
</div>

MyException.java

@XmlAccessorType(XmlAccessType.FIELD)
public class MyException extends Exception {

   @XmlJavaTypeAdapter(Cl1ToCl2Adapter.class)
    List<MyClass1> obj1;

    public MyClass1 getObj1() {
		return obj1;
    }
    
    public void setObj1(MyClass1 obj1) {
		this.obj1 = obj1;
	}
}


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;
	}
}

This is what the resulting WSDL contains. 
List of MyClass1 is ignored. XMLJavaTypeAdapter takes no effect on the list.
If only one MyClass1 is present (not a list, single object) it works fine.

<xs:complexType name="MyException">
  <xs:sequence>
    <xs:element name="message" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

  was:
@XMLJavaTypeAdapter usage in Exception Classes does not work when mapping to a list of objects
not in the JAXB Context.

MyEJB.java

@Stateless
@WebService
public class MyEJB {

    public void launcheMyException() throws MyException {
        return;
    }
}


MyException.java

@XmlAccessorType(XmlAccessType.FIELD)
public class MyException extends Exception {

   @XmlJavaTypeAdapter(Cl1ToCl2Adapter.class)
    List<MyClass1> obj1;

    public MyClass1 getObj1() {
		return obj1;
    }
    
    public void setObj1(MyClass1 obj1) {
		this.obj1 = obj1;
	}
}


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;
	}
}

This is what the resulting WSDL contains. 
List of MyClass1 is ignored. XMLJavaTypeAdapter takes no effect on the list.
If only one MyClass1 is present (not a list, single object) it works fine.

<xs:complexType name="MyException">
  <xs:sequence>
    <xs:element name="message" type="xs:string"/>
  </xs:sequence>
</xs:complexType>


> XMLJavaTypeAdapter not working in Exception Classes
> ---------------------------------------------------
>
>                 Key: CXF-6821
>                 URL: https://issues.apache.org/jira/browse/CXF-6821
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.7.17, 2.7.18
>         Environment: XMLJavaTypeAdapter not working in Exception Classes
>            Reporter: Marco
>             Fix For: Invalid
>
>
> @XMLJavaTypeAdapter usage in Exception Classes does not work when mapping to a list of
objects not in the JAXB Context.
> MyEJB.java
> <div class="code panel" style="border-width: 1px;">
> @Stateless
> @WebService
> public class MyEJB {
>     public void launcheMyException() throws MyException {
>         return;
>     }
> }
> </div>
> MyException.java
> @XmlAccessorType(XmlAccessType.FIELD)
> public class MyException extends Exception {
>    @XmlJavaTypeAdapter(Cl1ToCl2Adapter.class)
>     List<MyClass1> obj1;
>     public MyClass1 getObj1() {
> 		return obj1;
>     }
>     
>     public void setObj1(MyClass1 obj1) {
> 		this.obj1 = obj1;
> 	}
> }
> 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;
> 	}
> }
> This is what the resulting WSDL contains. 
> List of MyClass1 is ignored. XMLJavaTypeAdapter takes no effect on the list.
> If only one MyClass1 is present (not a list, single object) it works fine.
> <xs:complexType name="MyException">
>   <xs:sequence>
>     <xs:element name="message" type="xs:string"/>
>   </xs:sequence>
> </xs:complexType>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message