2

As I am new to Dozer, I implement it in our project .But when we are trying to storing the values into database MySQL.we are getting the following exception .But even searched in Google but they have told to configure the dozen in XML file.May i Know that is the problem I am facing

org.dozer.MappingException: Unable to locate dozer mapping file [dozer-bean-mappings.xml] in the classpath

Thanks In Advance...

vinay Maneti
  • 1,447
  • 1
  • 23
  • 31

2 Answers2

1

If that is maven driven project place the file in the resources folder.

and give the path as classpath:dozer-global-configuration.xml

Or

Place the file some where in your local drive and give the complete path, some thing like the below.

file:///C:/dozer-global-configuration.xml

see this and even this for better understanding.

Community
  • 1
  • 1
Vinay Veluri
  • 6,671
  • 5
  • 32
  • 56
  • file:///c:/test/application.properties in application.properties what can i find , i even don't have any file path which you have mentioned... – vinay Maneti Nov 18 '13 at 13:01
  • @ManetiVinay, the exception with the code that is given, code is not able to find the mapping file. Place your mapping file in some location of your drive and point that location to the mapping files list. file:///c:/dozer-global-configuration.xml file:///c:/dozer-bean-mappings.xml file:///c:/more-dozer-bean-mappings.xml . This is the place where the file location to be changed. – Vinay Veluri Nov 18 '13 at 14:08
  • file:///C:/dozer-global-configuration.xml This worked finally thanks! – mathan Jun 14 '21 at 15:26
0

You can use following code snippet :

final List<String> mappingFilesNames = new ArrayList<String>();

String path = new File("dozerBeanMapping.xml").getAbsolutePath();

mappingFilesNames.add("file:/"+path);

mapper.setMappingFiles(mappingFilesNames);

here dozerBeanMapping.xml is my mapping xml file placed in project directory:
ProjectDozer/dozerBeanMapping.xml

CSchulz
  • 10,882
  • 11
  • 60
  • 114