#150 Error in loading mapping files located in jar file

Dozer v4.4
closed
None
5
2008-12-16
2008-09-26
tdrencak
No

When I tried to configure dozer by MyDozerBeanMapperFactoryBean in spring with mapping files everything works OK while mapping files were located directly on file system. But when they were located in jar file, it complains about FindNotFoundException.

To solve this problem you need to change
mappings.add(MapperConstants.FILE_PREFIX + this.mappingFiles[i].getFile().toString());
to
mappings.add(this.mappingFiles[i].getURL().toString());
in DozerBeanMapperFactory. Below is fixed version of the method.

@SuppressWarnings("unchecked")
public final void afterPropertiesSet() throws Exception {
this.beanMapper = new DozerBeanMapper();

if (this.mappingFiles != null) {
final List mappings = new ArrayList(this.mappingFiles.length);
for (int i = 0; i < this.mappingFiles.length; i++) {
mappings.add(this.mappingFiles[i].getURL().toString());
}
this.beanMapper.setMappingFiles(mappings);
}
if (this.customConverters != null) {
this.beanMapper.setCustomConverters(this.customConverters);
}
if (this.eventListeners != null) {
this.beanMapper.setEventListeners(this.eventListeners);
}
if (this.factories != null) {
this.beanMapper.setFactories(this.factories);
}
}

Discussion

  • dmitry (lv)

    dmitry (lv) - 2008-09-29
    • assigned_to: nobody --> buzdin
     
  • Matt Tierney

    Matt Tierney - 2008-12-16

    This code has been applied

     
  • Matt Tierney

    Matt Tierney - 2008-12-16
    • milestone: --> Dozer v4.4
    • assigned_to: buzdin --> mhtierney
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks