0

我正在使用 Orika 在两个 java 对象之间进行映射。当我运行 junit 测试时,它工作正常 - 对象映射正确,但是当我执行在码头上运行的代码时,我得到了这个异常:

...
Caused by: java.lang.NoClassDefFoundError: Loracle/dms/console/DMSConsole;
at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_45]
at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_45]
at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_45]
at com.carrotsearch.sizeof.RamUsageEstimator.createCacheEntry(RamUsageEstimator.java:568) ~[java-sizeof-0.0.4.jar:na]
at com.carrotsearch.sizeof.RamUsageEstimator.measureSizeOf(RamUsageEstimator.java:532) ~[java-sizeof-0.0.4.jar:na]
at com.carrotsearch.sizeof.RamUsageEstimator.sizeOfAll(RamUsageEstimator.java:380) ~[java-sizeof-0.0.4.jar:na]
at com.carrotsearch.sizeof.RamUsageEstimator.sizeOfAll(RamUsageEstimator.java:361) ~[java-sizeof-0.0.4.jar:na]
at ma.glasnost.orika.StateReporter.humanReadableSizeInMemory(StateReporter.java:48) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.DefaultMapperFactory.reportCurrentState(DefaultMapperFactory.java:1547) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.StateReporter.reportCurrentState(StateReporter.java:33) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.ExceptionUtility.decorate(ExceptionUtility.java:65) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.MapperFacadeImpl.resolveMappingStrategy(MapperFacadeImpl.java:209) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.DefaultBoundMapperFacade$BoundStrategyCache.getStrategy(DefaultBoundMapperFacade.java:259) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.DefaultBoundMapperFacade.map(DefaultBoundMapperFacade.java:137) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.generated.LocalDate_LocalDate_ObjectFactory1257832766063212584156506661$3.create(LocalDate_LocalDate_ObjectFactory1257832766063212584156506661$3.java) ~[na:na]
at ma.glasnost.orika.impl.mapping.strategy.InstantiateAndUseCustomMapperStrategy.getInstance(InstantiateAndUseCustomMapperStrategy.java:55) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.mapping.strategy.UseCustomMapperStrategy.map(UseCustomMapperStrategy.java:61) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.DefaultBoundMapperFacade.map(DefaultBoundMapperFacade.java:137) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.generated.Orika_TransactionType_Transaction_Mapper12578333614376$1.mapAtoB(Orika_TransactionType_Transaction_Mapper12578333614376$1.java) ~[na:na]
at ma.glasnost.orika.impl.mapping.strategy.UseCustomMapperStrategy.map(UseCustomMapperStrategy.java:67) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:378) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:367) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:408) ~[orika-core-1.4.5.jar:na]
at ma.glasnost.orika.impl.ConfigurableMapper.map(ConfigurableMapper.java:158) ~[orika-core-1.4.5.jar:na]
...
Caused by: java.lang.ClassNotFoundException: oracle.dms.console.DMSConsole
...

我尝试以多种方式创建映射代码:(1)扩展 ConfigurableMapper 和(2)设置外观(类似于此):

MapperFactory factory = new DefaultMapperFactory.Builder().build();
factory.registerClassMap(factory.classMap(Order.class,OrderDTO.class)
  .field("product.state.type.label", "stateLabel")
  .field("product.name", "productName").toClassMap());

MapperFacade mapper = factory.getMapperFacade();

结果总是一样的,当我运行我的 junit 测试时它工作正常,但是当相同的代码作为码头内服务的一部分运行时它会失败。

我似乎无法理解 DMSConsole 与映射有什么关系。


更新

不知何故与 joda DateTime 映射有关,因为项目已移至 java.time,这不再是问题。

删除它解决了这个问题:

factory.getConverterFactory().registerConverter(new PassThroughConverter(DateTime.class));

我仍然看不到与异常的联系,所以我可能遗漏了一些东西,但不再是问题。

4

1 回答 1

0

您有类可见性问题,所以请您使用 MapperFactory.dumpStateOnException(false) 禁用异常转储状态并重新发送您的日志。

于 2015-04-26T00:07:51.657 回答