Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-418

Castor mappings are added multiple times

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.4
    • Fix Version/s: 1.5.5
    • Component/s: OXM
    • Labels:
      None

      Description

      When using multiple mapping files for castor the CastorMarshaller adds each mapping several times.

      i.e.
      <bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller" >
      <property name="mappingLocations">
      <list>
      <value>classpath:file1.xml</value>
      <value>classpath:file2.xml</value>
      <value>classpath:file3.xml</value>
      </list>
      </property>
      </bean>

      The mappings from file1 are added 3 times because the addMapping() method is called within the loop with the entire mapping.
      I think method

      protected XMLContext createXMLContext(Resource[] mappingLocations, Class targetClass)
      throws MappingException, IOException, ResolverException {
      XMLContext context = new XMLContext();
      if (!ObjectUtils.isEmpty(mappingLocations)) {
      Mapping mapping = new Mapping();
      for (int i = 0; i < mappingLocations.length; i++)

      { mapping.loadMapping(SaxUtils.createInputSource(mappingLocations[i])); context.addMapping(mapping); }

      }
      if (targetClass != null)

      { context.addClass(targetClass); }
      return context;
      }

      Should actually look like this

      protected XMLContext createXMLContext(Resource[] mappingLocations, Class targetClass)
      throws MappingException, IOException, ResolverException {
      XMLContext context = new XMLContext();
      if (!ObjectUtils.isEmpty(mappingLocations)) {
      Mapping mapping = new Mapping();
      for (int i = 0; i < mappingLocations.length; i++) { mapping.loadMapping(SaxUtils.createInputSource(mappingLocations[i])); }
      context.addMapping(mapping);
      }
      if (targetClass != null) { context.addClass(targetClass); }

      return context;
      }

      BTW: Adding mappings multiple times will result in strange behavior because Castor tries identify objects by their namespace if it finds multiple entries with the same name and fails because of bad namespace support within castor.

        Activity

        stu Andreas Stubenrauch created issue -
        arjen.poutsma Arjen Poutsma made changes -
        Field Original Value New Value
        Fix Version/s 1.5.5 [ 11067 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Fixed! Thanks for spotting this.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Fixed! Thanks for spotting this.
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing old issues

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing old issues
        arjen.poutsma Arjen Poutsma made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        7d 10h 11m 1 Arjen Poutsma 28/Aug/08 9:23 AM
        Resolved Resolved Closed Closed
        1344d 21h 40m 1 Arjen Poutsma 04/May/12 7:03 AM

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            stu Andreas Stubenrauch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: