0

Hybris: 製品コックピットは、コレクションの比較モードで ClassCastException をスローします。通常モードでは正常に動作します。

MyTypedObject をコレクションに明示的にキャストする方法は?

私のコードスニペット:

Collection<CategoryModel> pCategories = ProductModel.getSupercategories();
  for (CategoryModel parentCategory : pCategories) { //ClassCastExceptionthrown
            //do something
  } }

スタックトレース:

INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 | java.lang.ClassCastException: de.hybris.platform.cockpit.services.meta.impl.ExtensibleTypeService$MyTypedObject cannot be cast to de.hybris.platform.category.model.CategoryModel
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at com.org.comm.hybris.core.servicelayer.attributehandlers.DynamicTSCategoryHandler.get(DynamicTSCategoryHandler.java:42)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at com.org.comm.hybris.core.servicelayer.attributehandlers.DynamicTSCategoryHandler.get(DynamicTSCategoryHandler.java:1)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at de.hybris.platform.servicelayer.internal.model.attribute.impl.DefaultDynamicAttributesProvider.get(DefaultDynamicAttributesProvider.java:48)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at de.hybris.platform.servicelayer.model.ItemModelContextImpl.getDynamicValue(ItemModelContextImpl.java:281)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at com.org.comm.hybris.core.model.ProductModel.getMyTSSuperCategory(ProductModel.java:1669)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at java.lang.reflect.Method.invoke(Method.java:606)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:196)
INFO   | jvm 1    | main    | 2016/05/10 09:28:19.464 |     at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:181)
4

1 に答える 1