Share

Dozer

Tracker: Bugs

5 Dozer should load classes using ContextClassLoader - ID: 2487499
Last Update: Comment added ( buzdin )

Since Dozer4.3 dozer does not find classes in the context classloader, so
that we get net.sf.dozer.util.mapping.MappingException:
java.lang.ClassNotFoundException
when mapping classes located in the .war archive (dozer.jar is located in
the parent classloader, e.g. in the lib directory of the appserver).

This worked correctly in previous versions of dozer, because it used the
ContextClassLoader.

Class MappingUtils has been changed in Dozer4.3 (ff.) so that dozer only
finds classes that are in the same classload as dozer itself:

New Code (since 4.3)
public static Class loadClass(String name) {
Class result = null;
try {
result = Class.forName(name);
} catch (ClassNotFoundException e) {
MappingUtils.throwMappingException(e);
}
return result;
}

I suggest, that you revert the change and use the former code again, that
fixes the bug:

Code in Dozer4.2 and before:

public static Class loadClass(String name) {
Class result = null;
try {
result =
Thread.currentThread().getContextClassLoader().loadClass(name);
} catch (ClassNotFoundException e) {
MappingUtils.throwMappingException(e);
}
return result;
}

Best regards,
Roman Stumm


Roman Stumm ( roman_stumm ) - 2009-01-05 10:20

5

Closed

Fixed

Nobody/Anonymous

None

Dozer v4.4.1

Public


Comments ( 3 )

Date: 2009-01-10 14:45
Sender: buzdinProject Admin

Fixed, included in 4.4.1 release


Date: 2009-01-05 12:23
Sender: buzdinProject Admin

Thank you for reporting this issue.
We will be preparing 4.4.1 release with this fix in the closest time.


Date: 2009-01-05 10:35
Sender: roman_stumm

Another suggestion: Dozer is already using commons-lang

So the simplest way to load a class would be:
org.apache.commons.lang.ClassUtils.getClass(String name).

(org.apache.commons.lang.ClassUtils is also using the ContextClassLoader)


Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
status_id Open 2009-01-10 14:45 buzdin
resolution_id None 2009-01-10 14:45 buzdin
artifact_group_id None 2009-01-10 14:45 buzdin
close_date - 2009-01-10 14:45 buzdin