2 Replies Latest reply on Feb 27, 2015 10:01 AM by zerounix

    DefaultIdentity on domain mode clustered environment org.infinispan.commons.marshall.NotSerializableException

    zerounix

      Hi,

       

      we use wildfly 8.2. with session failover and picketlink 2.7.0.CR2. We @Inject an instance of Identity into our @Sessionscoped bean.


      Infinispan then tries to serialize the session data but fails with the following error:

       

      Caused by: org.infinispan.commons.marshall.NotSerializableException: org.jboss.weld.injection.producer.BeanInjectionTarget

      Caused by: an exception which occurred:

        in field injectionTarget

        in field serializable

        in field holder

        in field contextual

        in object java.util.HashMap@2e33ba80

        in object org.jboss.as.clustering.marshalling.SimpleMarshalledValue@2e33ba80

       

      After some digging into wildfly and picketlink source we could finally hunt it down to the change in PLINK-571

       

      The Picketlink Extension defined in PicketLinkExtension as follows:

          /**

           * <p>Initializes the PicketLink configuration.</p>

           *

           * @param abd

           * @param beanManager

           */

          void installIdentityBean(@Observes AfterBeanDiscovery abd, BeanManager beanManager) {

              this.identityBeanDefinition = new IdentityBeanDefinition(beanManager);

              abd.addBean(identityBeanDefinition);

          }

       

      and defines the Producer for the DefaultIdentity as:

       

      public class IdentityBeanDefinition implements Bean<DefaultIdentity>, Serializable, PassivationCapable {

       

          private static final long serialVersionUID = -4725126763788040967L;

       

          private final BeanManager beanManager;

          private final InjectionTarget<DefaultIdentity> injectionTarget;

          private SecurityConfiguration securityConfiguration;

       

      ...

       

           @Override

           public DefaultIdentity create(CreationalContext<DefaultIdentity> creationalContext) {

              DefaultIdentity identity = this.injectionTarget.produce(creationalContext);

       

              this.injectionTarget.inject(identity, creationalContext);

              this.injectionTarget.postConstruct(identity);

       

              return identity;

          }

       

      We found out that picketlink compiles against Weld 1.1. but wildfly uses 2.x and therefore a different version of the CDI API.

      Are there any changes this could effect the process of Serializazion?

       

      Our workaround is to deactivate the part of bean creation in the Extension and delete the class IdentityBeanDefinition and finally create our own Producer.

      After that serialization works perfectly.

       

      Could someone please confirm that, and explain the Weld/CDI problem? What could be a non hacky workaround?

       

      regards,

      Daniel