Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

JBoss AS 7 configured Infinispan cache-container, how to Inject through JNDI?

$
0
0
Hi everyone

For the setup:
I have a JBoss Cluster setup AS 7.1.1 of Infinispan with the following contai
Code:

            <cache-container name="test-cache" default-cache="test_repl" start="EAGER">
                <transport lock-timeout="60000"/>
                <replicated-cache name="test_repl" mode="SYNC" start="EAGER">
                    <locking isolation="REPEATABLE_READ"/>
                </replicated-cache>
            </cache-container>

I want to include this in my App by DI. Normally I would do a Resource lookup
Code:

@Resource(lookup = "java:jboss/infinispan/container/test-cache")
But no matter what I do this won't work. I tried with dedicated producers etc. but nothing worked. One of the most common errors I get is:
Code:

Key type [null] of map [org.infinispan.Cache] must be assignable to [java.lang.String]
And I do not get why. The code
Code:

        @Resource(lookup = "java:jboss/infinispan/container/test-cache")
        CacheContainer jbossCacheContainer;
       
        @Produces
        @JBossCache
        public Cache jbossCache() {
                return jbossCacheContainer.getCache();
        }

Already the single Resource Lookup throws him out with errors.

I found this link http://timtang.me/blog/2012/11/04/in...n-integration/ which actually lead to the very first time that I was able to have a cache manager in my spring-based application. Before, nothing worked at all, and all examples I found were with custom configuration and not on the JBoss embedded cache-container.

The problem with that implementation is that it is not Infinispan typed, but wraps everything in e.g. SpringCache etc. I could get the native implementations and wrap this in a custom class of course, but I am not sure if this is the best way. Shouldn't it be possible to grap the resource directly?

I am sorry if I am missing something here, but I poked around the internet for several days now with a colleague, and the issue we have is the CDI based Infinispan way "does not compute" ^^ with the Spring way it seems.

Any help is very appreciated. If you need more info, just let me know.


Thanks in advance for any hint, Best

Viewing all articles
Browse latest Browse all 297

Trending Articles