Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5246

Conflicting schema namespaces for services with same set of schema classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.7.6
    • 2.6.10, 2.7.7, 3.0.0-milestone1
    • JAXB Databinding
    • None
    • CXF Services with JAXB Databinding

    • Unknown

    Description

      In case of services, which have the exact same set of schema classes, it may occur that the generated schema namespace of the server service is different from the generated schema namespace of the client service, depending on the order of their initialization. This can result in non-functioning services (see attached sample project).

      Errors like this occur:

      javax.xml.bind.UnmarshalException: unknown type name: {http://bar.service/}barName. Did you mean {http://foo.service/}barName?
      

      The cause is the caching of schemas in JAXBDatabinding, which will reuse a schema if the set of contextClasses are equal (see method JAXBDatabinding.createJAXBContextAndSchemas() and class JAXBContextCache). The problem is that it will use the package of the current service as the target namespace for the schema. So it may happen that the target namespaces differ between client and server side, depending on the order of initialization of the services which have an equal set of schema classes.

      Our current workaround for this problem is to specify equal target namespaces (e.g. by setting @WebService(targetNamespace = "http://reused.target.namespace")) for the affected services so the order of their initialization does not matter anymore.

      Another workaround could be to give each service an individual DataBinding without overlapping schema types. But that would require extra coding effort on server and client side.

      Maybe you could change the key of the JAXBCONTEXT_CACHE map in the JAXBContextCache class to also contain the target namespace (or the schema class) so different services would get different schemas.

      Attachments

        1. cfx-wrong-namespace.zip
          10 kB
          Kai Stapel

        Activity

          People

            ffang Freeman Yue Fang
            kai.stapel Kai Stapel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: