cancel
Showing results for 
Search instead for 
Did you mean: 

ClassCastException during hybris initialization

Former Member
2,137

Hello everyone,

During hybris initialization by ant initialize a ClassCastException is thrown and it is getting init process stuck.

The hybris version we are using is 6.6.0.0. This exception is thrown randomly, so the next time I start init the process can continue with no issues. This exception is thrown on different local workstation as well as on the server instances. The database is not an issue as well since it is reproducible on MySQL, SAP Hana, HSQLD.

Currently we just want to customize RemoveDataOnSetURLPrepareInterceptor, but I am curious if someone know the root cause of this issue?

 [java]  de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.media.interceptors.RemoveDataOnSetURLPrepareInterceptor@41945ff2]: unexpected preparer error: Cannot cast class de.hybris.platform.core.model.audit.AuditReportConfigModel to class de.hybris.platform.core.model.media.MediaModel
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.wrapper.ModelWrapper.invokePrepareInterceptors(ModelWrapper.java:279) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.wrapper.ModelWrapper.executeInterceptorsAndCascade(ModelWrapper.java:108) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.extractor.impl.DefaultModelExtractor.process(DefaultModelExtractor.java:44) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.performPersistenceOperations(DefaultModelService.java:720) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.saveAllInternal(DefaultModelService.java:715) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.saveAll(DefaultModelService.java:695) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.save(DefaultModelService.java:643) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.audit.internal.config.DefaultAuditConfigService.storeConfiguration(DefaultAuditConfigService.java:137) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.audit.internal.config.DefaultAuditConfigService.storeConfiguration(DefaultAuditConfigService.java:125) ~[coreserver.jar:?]
      [java]     at java.util.HashMap$Values.forEach(HashMap.java:981) ~[?:1.8.0_152]
      [java]     at de.hybris.platform.audit.internal.config.DefaultAuditConfigService.storeConfigurations(DefaultAuditConfigService.java:101) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.Initialization.storeGenericAuditConfigurations(Initialization.java:1008) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.Initialization.doInitializeImpl(Initialization.java:569) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.Initialization.access$5(Initialization.java:466) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.Initialization$5.call(Initialization.java:787) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.Initialization$5.call(Initialization.java:1) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.system.InitializationLockHandler.performLocked(InitializationLockHandler.java:80) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.core.Initialization.doInitialize(Initialization.java:819) ~[coreserver.jar:?]
      [java]     at de.hybris.ant.taskdefs.InitPlatformAntPerformableImpl.performImpl(InitPlatformAntPerformableImpl.java:106) ~[coreserver.jar:?]
      [java]     at de.hybris.ant.taskdefs.AbstractAntPerformable.doPerform(AbstractAntPerformable.java:92) [coreserver.jar:?]
      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
      [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
      [java]     at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
      [java]     at bsh.Reflect.invokeMethod(Reflect.java:134) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.Reflect.invokeObjectMethod(Reflect.java:80) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.Name.invokeMethod(Name.java:858) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.Interpreter.eval(Interpreter.java:645) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.Interpreter.eval(Interpreter.java:739) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at bsh.Interpreter.eval(Interpreter.java:728) [bsh-2.0b5.jar:2.0b5 2005-06-12 04:50:41]
      [java]     at de.hybris.platform.util.ClientExecuter.execute(ClientExecuter.java:49) [coreserver.jar:?]
      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
      [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
      [java]     at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
      [java]     at de.hybris.bootstrap.loader.Loader.execute(Loader.java:142) [ybootstrap.jar:?]
      [java]     at de.hybris.bootstrap.loader.Loader.main(Loader.java:118) [ybootstrap.jar:?]
      [java] Caused by: java.lang.ClassCastException: Cannot cast class de.hybris.platform.core.model.audit.AuditReportConfigModel to class de.hybris.platform.core.model.media.MediaModel
      [java]     at de.hybris.platform.media.interceptors.RemoveDataOnSetURLPrepareInterceptor.onPrepare(RemoveDataOnSetURLPrepareInterceptor.java:1) ~[coreserver.jar:?]
      [java]     at de.hybris.platform.servicelayer.internal.model.impl.wrapper.ModelWrapper.invokePrepareInterceptors(ModelWrapper.java:270) ~[coreserver.jar:?]
      [java]     ... 39 more
      [java] Caused by: Sourced file: inline evaluation of: ``de.hybris.ant.taskdefs.AntPerformable p = new de.hybris.ant.taskdefs.InitPlatfor . . . '' : Method Invocation p.doPerform : at Line: 2 : in file: inline evaluation of: ``de.hybris.ant.taskdefs.AntPerformable p = new de.hybris.ant.taskdefs.InitPlatfor . . . '' : p .doPerform ( ) 
      [java] 
      [java] Target exception: de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.media.interceptors.RemoveDataOnSetURLPrepareInterceptor@41945ff2]: unexpected preparer error: Cannot cast class de.hybris.platform.core.model.audit.AuditReportConfigModel to class de.hybris.platform.core.model.media.MediaModel
      [java] 
      [java]     at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:97)
      [java]     at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
      [java]     at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
      [java]     at bsh.Interpreter.eval(Interpreter.java:645)
      [java]     at bsh.Interpreter.eval(Interpreter.java:739)
      [java]     at bsh.Interpreter.eval(Interpreter.java:728)
      [java]     at de.hybris.platform.util.ClientExecuter.execute(ClientExecuter.java:49)
      [java]     ... 6 more





Former Member
0 Kudos

Hi ,

I am curious to know if you got any solution for it .

Thank you.

Former Member
0 Kudos

Hello Vijaya,

Yes, we have fixed an issue by replacing OOTB RemoveDataOnSetURLPrepareInterceptor by our CustomRemoveDataOnSetURLPrepareInterceptor.

In the CustomRemoveDataOnSetURLPrepareInterceptor:

 public void onPrepare(ItemModel item, InterceptorContext ctx) {
      if (item instanceof MediaModel) {
             ....
         }
  }
Former Member
0 Kudos

Thank you MyKyta .. It worked :)

Former Member
0 Kudos

Can you confirm that the issue appeared while developing on 6.6.x or only when switching from 6.6.x to 6.7.x?

Also: did the error show in a platform only / limited setup or only when you included accelerators?

This would definitely help getting to the root cause.

Thank you Axel

former_member915156
Participant
0 Kudos

Reproduced on 6.7 using Mysql on CentOS. It's not all the time. Can't reproduce on windows using hsqldb.

Accepted Solutions (1)

Accepted Solutions (1)

abderzakeboufeta
Explorer

In case you wondered, the issue is still present on the latest Hybris version (18.08).

It will be fixed in the next release, scheduled for November(18.11). Until then, we'll need to stick with the fix :)!

Regards.

Answers (5)

Answers (5)

0 Kudos

Hey, I had that problem too, try to delete your database and create a new one and then do the ant initialize. Worked for me.

glennvs_elision
Explorer
0 Kudos
nicolabeghin-2
Advisor
Advisor
0 Kudos

We got the same error, fixed by following suggestion! BTW we had to hack the core, so an official bugfix should be in order :D

Former Member
0 Kudos

Any solution for this error? I have the same.

abderzakeboufeta
Explorer
0 Kudos

Hi all, I'm also facing the issue on a fresh 6.7.0 (upgrading from 6.6.0) when initializing the system .

Cannot cast class de.hybris.platform.core.model.audit.AuditReportConfigModel to class de.hybris.platform.core.model.media.MediaModel

This doesn't always occur, but the initialization exits after this error leaving the database in an inconsistent state.

The RemoveDataOnSetURLPrepareInterceptor is mapped as a Prepare Intercerptor for Media items (see media-spring.xml), but clearly a AuditReportConfigModel instance IS NOT a Media; it extends AbstractDynamicContentModel which itself directly extends ItemModel.

So, I'm pretty sure that this is an out-of-the-box bug.

As there doesn't seem the be a way to deactivate this audit report saving, I'm going to (reluctantly) implement the workaround check mentioned by .

Regards.

former_member641349
Discoverer
0 Kudos

Hi Abderzake, I think I can confirm your guess that it must be an ootb bug, for details see my post on the duplicate thread https://answers.sap.com/questions/12768451/view.html.

abderzakeboufeta
Explorer
0 Kudos

Hi Andreas, You indeed did a great job of actually going through the investigation! The good news is that you have tracked down the probable root cause and confirmed the issue. The bad news is that a corrupt type system cache seems to me like a serious bug; hopefully we'll get this fixed soon.

Thanks!