0 Replies Latest reply on Mar 9, 2018 7:29 AM by cardel

    Wildfly 10.1.0 - infinispan - JNDI - org.springframework.jndi.TypeMismatchNamingException

    cardel

      Hi,

      we are facing one issue after upgrade from WF8 to WF10.

       

      Our application is using infinispan cache. Sometimes we are receiving error (mentioned bellow) when deployment of the application starts. It is connected only with development machines when the application is deployed from Intellij IDE. When we are deploying app as packaged WAR to external test/prod servers everything is working without problems.

      Sometimes is deploy on dev machine completed correctly sometimes not.

       

      Error creating bean with name 'codeTableDao' defined in VFS resource [....CodeTableDao.class"]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.interceptor.CacheInterceptor#0': Cannot resolve reference to bean 'cacheManager' while setting bean property 'cacheManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManager' defined in class path resource [core-context.xml]: Cannot resolve reference to bean 'nativeCacheManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nativeCacheManager': Invocation of init method failed; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class org.jboss.as.clustering.infinispan.DefaultCacheContainer] available at JNDI location [java:jboss/infinispan/container/app] is not assignable to [org.infinispan.manager.EmbeddedCacheManager]

      This is part of our core-context xml with bean definition

       

      <beans xmlns="http://www.springframework.org/schema/beans"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"

      xmlns:context="http://www.springframework.org/schema/context"

      xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:jee="http://www.springframework.org/schema/jee"

      xmlns:aop="http://www.springframework.org/schema/aop"

      xsi:schemaLocation="http://www.springframework.org/schema/beans

          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

          http://www.springframework.org/schema/data/jpa

          http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd

          http://www.springframework.org/schema/jee

          http://www.springframework.org/schema/jee/spring-jee.xsd

          http://www.springframework.org/schema/context

          http://www.springframework.org/schema/context/spring-context-3.2.xsd

          http://www.springframework.org/schema/aop

          http://www.springframework.org/schema/aop/spring-aop.xsd">

       

      <context:annotation-config />

      <context:component-scan base-package=" ........ " />

       

      <jee:jndi-lookup id="nativeCacheManager"

      expected-type="org.infinispan.manager.EmbeddedCacheManager" jndi-name="java:jboss/infinispan/container/app" />

       

      <bean id="cacheManager"

      class="org.infinispan.spring.provider.SpringEmbeddedCacheManager">

      <constructor-arg>

      <ref bean="nativeCacheManager" />

      </constructor-arg>

      </bean>

       

      This is our infinispan definition from standalone.xml

       

      <subsystem xmlns="urn:jboss:domain:infinispan:4.0">

                  <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">

                      <local-cache name="passivation">

                          <transaction mode="BATCH"/>

                          <file-store passivation="true" purge="false"/>

                      </local-cache>

                      <local-cache name="persistent">

                          <transaction mode="BATCH"/>

                          <file-store passivation="false" purge="false"/>

                      </local-cache>

                      <local-cache name="concurrent">

                          <file-store passivation="true" purge="false"/>

                      </local-cache>

                  </cache-container>

                  <cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">

                      <local-cache name="passivation">

                          <transaction mode="BATCH"/>

                          <file-store passivation="true" purge="false"/>

                      </local-cache>

                      <local-cache name="persistent">

                          <transaction mode="BATCH"/>

                          <file-store passivation="false" purge="false"/>

                      </local-cache>

                  </cache-container>

                  <cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">

                      <local-cache name="entity">

                          <transaction mode="NON_XA"/>

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="100000"/>

                      </local-cache>

                      <local-cache name="local-query">

                          <transaction mode="NONE"/>

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="100000"/>

                      </local-cache>

                      <local-cache name="timestamps">

                          <transaction mode="NONE"/>

                          <eviction strategy="NONE"/>

                      </local-cache>

                  </cache-container>

                  <cache-container name="app" default-cache="captcha-cache">

                      <local-cache name="captcha-cache">

                          <transaction mode="NON_XA"/>

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="600000"/>

                      </local-cache>

                      <local-cache name="serviceState-cache">

                          <transaction mode="NON_XA"/>

                          <eviction strategy="LRU" max-entries="1000"/>

                          <expiration max-idle="-1"/>

                      </local-cache>

                      <local-cache name="token-cache">

                          <transaction mode="NON_XA"/>

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration lifespan="5000"/>

                      </local-cache>

                      <local-cache name="codeTables-cache">

                          <locking isolation="READ_COMMITTED"/>

                          <transaction locking="OPTIMISTIC" mode="NON_XA"/>

                          <eviction strategy="LRU" max-entries="10000"/>

                          <expiration max-idle="60000"/>

                      </local-cache>

                  </cache-container>

                  <cache-container name="server" default-cache="default" module="org.wildfly.clustering.server">

                      <local-cache name="default">

                          <transaction mode="BATCH"/>

                      </local-cache>

                  </cache-container>

              </subsystem>

       

       

      And usage of codeTables-cache in the application

      @Component
      public class CodeTableDao {

         private static final String CACHE_NAME = "codeTables-cache";

         @Override
        @CacheEvict(value = CACHE_NAME, allEntries = true)
         public int insertCodeTable(.......) {

       

      Application will start correctly sometimes but also sometimes fails on TypeMismatchNamingException.

      Sometimes there is correct object (org.infinispan.manager.EmbeddedCacheManager) on JNDI path java:jboss/infinispan/container/app and sometimes there is org.jboss.as.clustering.infinispan.DefaultCacheContainer and application fails to start.

       

      We usually stop application server, start it again and problem will not occur again. But sometimes it is blocking us for a longer period.

       

      Do you have some tips or workaround?

       

      Thanks

       

      Karel