Below is the ear structure
ex.ear | |_lib-util.jar--CommonUtil.class,CommonException.class etc. | | | ejb.jar web.war
When I call this specific class like this (CommonUtil.map(empDto)) in WEB and EJB layer classes then we are getting a NoClassDefFoundError. Remaining all classes which are in Util.jar are all getting called normally. Why are we getting this error only for this class?
EmployeeDTO empDto = new EmployeeDTO();
empDto.setId(1);
empDto.setName("john");
CommonUtil.map(empDto);
public class CommonUtil {
private static Mapper mapper = new BeanMapper();
private static CommonUtil instance = new CommonUtil();
private CommonUtil() {
super();
}
public static <T> T map(Object source) {
T target = mapper.map(source);
return target;
}
public static <T> T map(Object source) {
mapper.map(source);
return target;
}
}
Generally speaking the
NoClassDefFoundErrorhappens if an Exception occurs during the static initialization. Please check the log priorNoClassDefFoundErrorcarefully if any exception happened during instantiatingBeanMapperorCommonUtil.