Menu

#137 Problem loading Dozer bean mapper from Spring

Dozer v4.4
closed-fixed
None
5
2014-08-28
2008-03-20
No

When using Dozer to load the mapping file, the mapping file must be directly between the <value></value> tags otherwise it fails to load. It appears to attempt to include any whitespace that is present in the filename.

For example:

<!-- Dozer bean mapper -->
<bean id="mapper" class="net.sf.dozer.util.mapping.DozerBeanMapper">
<property name="mappingFiles">
<list>
<!-- the name of the dozer configuration file -->
<value>
dozerMapper.xml
</value>
</list>
</property>
</bean>

Produces the stack trace which follows.

Changing the value tag to read:

<value>dozerMapper.xml</value>

is a current workaround. An example eclipse project which demonstrates this issue is attached.

Stack Trace:
net.sf.dozer.util.mapping.MappingException: Unable to locate dozer mapping file [
dozerMapper.xml
] in the classpath!!!
at net.sf.dozer.util.mapping.util.MappingUtils.throwMappingException(MappingUtils.java:96)
at net.sf.dozer.util.mapping.util.MappingValidator.validateURL(MappingValidator.java:59)
at net.sf.dozer.util.mapping.util.CustomMappingsLoader.load(CustomMappingsLoader.java:58)
at net.sf.dozer.util.mapping.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:149)
at net.sf.dozer.util.mapping.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:132)
at net.sf.dozer.util.mapping.DozerBeanMapper.map(DozerBeanMapper.java:98)
at com.sample.dozer.TestDozer.testDozer(TestDozer.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Discussion

  • Daniel Barbato

    Daniel Barbato - 2008-03-20

    Sample Eclipse Project

     
  • dmitry (lv)

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

    dmitry (lv) - 2008-09-30
    • status: open --> closed-fixed
     
  • dmitry (lv)

    dmitry (lv) - 2008-09-30

    This bug is fixed by applying trim() operation on the file name before loading it.
    Thank for reporting the flaw.

     
  • dmitry (lv)

    dmitry (lv) - 2008-10-30
    • milestone: --> 888638
     
  • Matt Tierney

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

    Matt Tierney - 2008-12-16

    Reopening. Was not fixed in 4.3

     
  • Matt Tierney

    Matt Tierney - 2008-12-16
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.