Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-3690

XMLJavaTypeAdapter not working in Exception Classes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • jbossws-cxf-4.2.2
    • jbossws-cxf-4.2
    • jbossws-cxf
    • None

    Description

      @XMLJavaTypeAdapter usage in Exception Classes does not work when mapping to a class 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)
          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;
          }
      }
      
      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. Obj2 is mapped fine to a String, but MyClass1 is not and should have the MyClass2 mapping here.

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

      If you add the same adapter to a non Exception class it works just fine.

      This is NOT a duplicate of JBWS-3552 as I believe in that use case only known JAXB types were tested (HashMap, Strings etc). This issue is when you are using custom classes that need to be mapped.

      Attachments

        1. cxfTest.jar
          8 kB
        2. cxf5219.diff
          2 kB

        Issue Links

          Activity

            People

              rhn-support-mus Mustafa Musaji
              rhn-support-mus Mustafa Musaji
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: