We're updating the issue view to help you get more done. 

ClassCastException in AbstractLoadPlanBuildingAssociationVisitationStrategy

Description

I am trying to use hibernate 4.3.0.Beta5 and slf4j (logback backend) in a simple project. It is failing with this stack trace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.hibernate.loader.plan2.build.spi.AbstractLoadPlanBuildingAssociationVisitationStrategy$MDCStack at org.hibernate.loader.plan2.build.spi.AbstractLoadPlanBuildingAssociationVisitationStrategy.mdcStack(AbstractLoadPlanBuildingAssociationVisitationStrategy.java:119) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.plan2.build.spi.AbstractLoadPlanBuildingAssociationVisitationStrategy.pushToStack(AbstractLoadPlanBuildingAssociationVisitationStrategy.java:114) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.plan2.build.spi.AbstractLoadPlanBuildingAssociationVisitationStrategy.startingEntity(AbstractLoadPlanBuildingAssociationVisitationStrategy.java:190) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitEntityDefinition(MetamodelGraphWalker.java:108) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitEntity(MetamodelGraphWalker.java:71) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.plan2.build.spi.MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan(MetamodelDrivenLoadPlanBuilder.java:53) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.<init>(AbstractLoadPlanBasedEntityLoader.java:80) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.plan.EntityLoader.<init>(EntityLoader.java:135) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.plan.EntityLoader.<init>(EntityLoader.java:56) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.plan.EntityLoader$Builder.byUniqueKey(EntityLoader.java:99) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.plan.EntityLoader$Builder.byPrimaryKey(EntityLoader.java:95) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.plan.AbstractBatchingEntityLoaderBuilder.buildNonBatchingLoader(AbstractBatchingEntityLoaderBuilder.java:47) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.loader.entity.BatchingEntityLoaderBuilder.buildLoader(BatchingEntityLoaderBuilder.java:76) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2501) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2523) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:3888) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3870) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:477) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1853) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:854) ~[hibernate-entitymanager-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:847) ~[hibernate-entitymanager-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:396) ~[hibernate-core-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:846) ~[hibernate-entitymanager-4.3.0.Beta5.jar:4.3.0.Beta5] at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:146) ~[hibernate-entitymanager-4.3.0.Beta5.jar:4.3.0.Beta5]

This is because in org.jboss.logging.Slf4jLoggerProvider.putMdc(String, Object) the MDCStack is converted to a String so when it is read back in org.hibernate.loader.plan2.build.spi.AbstractLoadPlanBuildingAssociationVisitationStrategy.mdcStack() it won't be an MDCStack anymore.

Environment

slf4j logbinding

Status

Assignee

Steve Ebersole

Reporter

AttilaA

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.0.Beta5

Priority

Critical