Hi,

Tuscany treats POJOs as JAXB objects following the default Java/XML mapping 
rules defined by JAXB. Your case is described in JAXB 2.1 spec (8.2.8 
Property/Field Name Collision).

A simple change can fix your problem. 

public class Employee {
    private String name = "keetarp"; // Make it private to avoid JAXB complaint 
about duplicate property

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

Or you can use @XmlTransient to resolve the name collision by preventing the 
mapping of either the public field or the property 


Thanks,
Raymond


From: Prateek Temkar 
Sent: Thursday, February 12, 2009 3:16 PM
To: [email protected] 
Subject: Exception while generating WSDL


Hi All,

      I've been working on exposing some POJO as a SOAP service and have been 
getting the following exception:

SEVERE: Exception thrown was: org.osoa.sca.ServiceRuntimeException: com.sun.xml.
bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExcept
ions.

This does not happen with plain Axis2 but Tuscany 1.3.2+ does not use Axis2 for 
java2wsdl if I'm not wrong. I don't see the exception in Tuscany 1.2.

Let me explain with a simple example. It is a slight modification to the 
calculator-ws-webapp example
--------------------------------------------------------------------------------------------------------------------------------------------------
@Service(AddService.class)
public class AddServiceImpl implements AddService {

    String name;
    
    public double add(double n1, double n2) {
        System.err.println("Adding " + n1 + " to " + n2);
        return n1 + n2;
    }
    
    public String getName(Employee employee) {
        return this.name;
    }

    public void setName(Employee employee) {
        this.name = employee.getName();
    }

}


public class Employee {
    public String name = "keetarp";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    
}

------------------------------------------------------------------------------------------------------------------------------
the problem here is that the field 'name' Employee class is public and so are 
its getters/setters. I know its not a good coding practice but I cannot change 
that code to make 'name' private

here are the container logs for tuscany 1.4


WARNING: Exception while generating WSDL for AddServiceComponent/AddService
Feb 12, 2009 12:03:47 PM org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGe
nerator
SEVERE: Exception thrown was: org.osoa.sca.ServiceRuntimeException: com.sun.xml.
bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExcept
ions
Class has two properties of the same name "name"
        this problem is related to the following location:
                at public java.lang.String calculator.Employee.getName()
                at calculator.Employee
        this problem is related to the following location:
                at public java.lang.String calculator.Employee.name
                at calculator.Employee

Feb 12, 2009 12:03:47 PM org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGe
nerator
WARNING: Exception while generating WSDL for CalculatorServiceComponent/addServi
ce
Feb 12, 2009 12:03:47 PM org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGe
nerator
SEVERE: Exception thrown was: org.osoa.sca.ServiceRuntimeException: com.sun.xml.
bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExcept
ions
Class has two properties of the same name "name"
        this problem is related to the following location:
                at public java.lang.String calculator.Employee.getName()
                at calculator.Employee
        this problem is related to the following location:
                at public java.lang.String calculator.Employee.name
                at calculator.Employee


 

Does Tuscany's java2wsdl processing perform this check? 

thnx,
Prateek Temkar

Reply via email to