IllegalAnnotationException: Two classes have the same XML type name

I found the cause of my problem.

This problem occurs because JAX-WS generates a class for each method and the class name is constructed by concatenating methodName + "Response". In my case, the newly generated class by JAX-WS will have the same name as my response object.

Example:

@Stateless
@WebService()
public class AccountWS {

    @WebMethod()
    public CreateAccountResponse createAccount(@WebParam(name = "request") CreateAccountRequest request) {
        return null;
    }
}

JAX-WS will generate a new class CreateAccountResponse for Web Method createAccount which has the same name as the response object.

Solution:

Make sure that the name of the response object and method doesn’t match. The same thing applies to the method parameter as well.

Leave a Comment