javaweb-servicessoapjax-wsjaxws-maven-plugin

Class java.util.Map not public or does not allow instantiation with auto generated classes in WebService


I have a WSDL provided by a partner, based on the OTA standard http://www.opentravel.org/OTA/2003/05.

I generated a Java Client using jaxws-maven-plugin to auto generate Java classes. The port is available through a ServiceClient that provides the methods. Until here, no problem at all.

The problems come when, for testing purposes, we need to create a mock implementation of the WebService.

I've done this with other WebServices and didn't get any errors, but for this one I get the following error when implementing the Interface's method:

Web method problem:Class java.util.Map not public or does not allow instantiation

So my interface looks like this:

@WebService(name = "DistributorsV1Port", targetNamespace = "http://www.opentravel.org/OTA/2003/05")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
        ObjectFactory.class
})
public interface ServiceMock extends ServiceDispatcher<Object, Object> {

    @WebMethod(operationName = "GetMultiAvailability")
    @WebResult(name = "OTA_HotelAvailRS", targetNamespace = "http://www.opentravel.org/OTA/2003/05", partName = "response")
    public OTAHotelAvailRS getMultiAvailability(
        @WebParam(name = "OTA_HotelAvailRQ", targetNamespace = "http://www.opentravel.org/OTA/2003/05", partName = "request")
                OTAHotelAvailRQ request);

And the implementation is as follows:

@WebService(name = "DistributorsV1Port", targetNamespace = "http://www.opentravel.org/OTA/2003/05")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
        ObjectFactory.class
})
public class ServiceMockImpl extends ServiceDispatcherImpl<Object, Object> implements ServiceMock {

    @Override
    public OTAHotelAvailRS getMultiAvailability(OTAHotelAvailRQ request) {
        return (OTAHotelAvailRS) dispatch(request);
    }
}

So what I understand, is that one of the attributes of the OTAHotelAvailRQ is a map, and @WebService doesn't like returning Maps. But this class has been auto generated by jax-ws plugin, so I'm getting a bit lost.

This is the attribute:

@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap();

If more code is helpful, please request the classes you would like to see.


Solution

  • The problem was finally solved by removing:

    @WebService(name = "DistributorsV1Port", targetNamespace = "http://www.opentravel.org/OTA/2003/05")
    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    @XmlSeeAlso({
            ObjectFactory.class
    })
    

    From the implementation. As those annotations are inherited, I didn't need them there, and then IntelliJ won't complain anymore.

    Anyways, having them there shouldn't be a problem, and I guess this is an issue with IntelliJ's warnings.