I need to create a simple infinispan cache on an application that uses Spring (no spring boot) and runs on WildFly 17.0.1.Final. I configured everything and wrote the Java code, but when I try to run it locally on my PC I get this error:
23:12:52,476 WARN [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 96) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webAppConfig': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'java:jboss/infinispan/cache/session/user-data' is expected to be of type 'org.infinispan.Cache' but was actually of type 'org.jboss.as.clustering.infinispan.DefaultCache'
However, on my colleague's PC it does not give an error and works normally.
Java code:
@Configuration
@ComponentScan("aaa.bbb")
@EnableWebMvc
@PropertySource(value = {"classpath:config.properties"})
@EnableScheduling
public class WebAppConfig implements WebMvcConfigurer{
@Autowired
private Environment env;
@Resource(lookup = "java:jboss/infinispan/cache/session/user-data") Cache<Object, Object> cache;
@Bean
public Cache<Object, Object> cacheManager() throws Exception {
return cache;
}
}
POM:
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-spring</artifactId>
<version>8.2.4.Final</version>
</dependency>
<profiles>
<profile>
<id>AAA</id>
<properties>
<application>NAMEEE</application>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<archive>
<manifestEntries><Dependencies>org.infinispan, org.infinispan.commons, org.jboss.as.clustering.infinispan export</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
<finalName>NAMEEE</finalName>
</build>
</profile>
</profiles>
WildFly standalone-full.xml:
<subsystem xmlns="urn:jboss:domain:infinispan:8.0">
<cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
<local-cache name="passivation">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="sso">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
</local-cache>
<local-cache name="routing"/>
</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>
<cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">
<local-cache name="passivation">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store passivation="true" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="hibernate" module="org.infinispan.hibernate-cache">
<local-cache name="entity">
<object-memory size="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="local-query">
<object-memory size="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="timestamps"/>
</cache-container>
<cache-container name="session" default-cache="user-data">
<local-cache name="user-data">
<locking concurrency-level="1000" isolation="READ_COMMITTED"/>
<transaction locking="OPTIMISTIC" mode="NON_XA"/>
</local-cache>
</cache-container>
</subsystem>