0
我正在使用Orika在兩個java對象之間進行映射。當我運行JUnit測試,它工作正常 - 對象已正確映射,但是當我執行在碼頭上運行的代碼,我得到這個異常:當應用程序在Jetty上運行時,Orika無法映射
...
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與映射有什麼關係。
更新
某種程度上與喬達日期時間映射,如該項目已經轉移到java.time,這不再是一個問題。
刪除這個問題得到了解決:
factory.getConverterFactory().registerConverter(new PassThroughConverter(DateTime.class));
我還沒有看到異常的連接,所以我可能失去了一些東西,但不再是一個問題。