4 Replies Latest reply: Dec 19, 2011 9:40 AM by hantsy bai RSS

My first Infinispan question...create multi cache using CDI.

hantsy bai Master

I tried to create a simple example, which using infinispan to store my data, I categoried the data as four types, I want to create 4 cache for different types.

 

I selected the simple way, creating cache using embeded manager...

 

I used a Resources class to generate different Configuration for 4 different type of caches.

 

 

@ConfigureCache("signup-unconfirmed-cache") // this is the cache name.
    @UnconfirmedCache // this is the cache qualifier.
    @Produces
    @ApplicationScoped
    public Configuration unconfirmedCacheConfiguration() {
        return new Configuration().fluent().eviction().strategy(EvictionStrategy.FIFO).maxEntries(10)
                    .build();
    }
    
    

    @ConfigureCache("signup-confirmed-cache") // this is the cache name.
    @ConfirmedCache // this is the cache qualifier.
    @Produces
    @ApplicationScoped
    public Configuration confirmedCacheConfiguration() {
        return new Configuration().fluent().eviction().strategy(EvictionStrategy.FIFO).maxEntries(10)
                    .build();
    }


    @ConfigureCache("signup-approved-cache") // this is the cache name.
    @ApprovedCache // this is the cache qualifier.
    @Produces
    @ApplicationScoped
    public Configuration approvedCacheConfiguration() {
        return new Configuration().fluent().eviction().strategy(EvictionStrategy.FIFO).maxEntries(10)
                    .build();
    }
    
    
    @ConfigureCache("signup-denied-cache") // this is the cache name.
    @DeniedCache // this is the cache qualifier.
    @Produces
    @ApplicationScoped
    public Configuration deniedCacheConfiguration() {
        return new Configuration().fluent().eviction().strategy(EvictionStrategy.FIFO).maxEntries(10)
                    .build();
    }

 

 

But when I injected the Cache in the beans, sometime I got the CDI exception form the infinispan,

 

 

javax.servlet.ServletException: java.lang.RuntimeException: Exception invoking method [getAdvancedCache] on object [org.infinispan.cdi.AdvancedCacheProducer@14dbc72], using arguments [Manager
Enabled alternatives: [] []
Registered contexts: [interface javax.enterprise.context.Dependent, interface javax.enterprise.context.ApplicationScoped, interface javax.enterprise.context.SessionScoped, interface javax.inject.Singleton, interface javax.enterprise.context.RequestScoped, interface javax.enterprise.context.ConversationScoped]
Registered beans: 152
Specialized beans: 0
]
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
 org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
 org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
 org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

 

It is strange that the Configuration is decrapted in the infinispan 5.1.0CR1, but I can not find the alternative in the Docuemnt and Getting Started Lab...

 

I have read the Getting Started Guide, and download the lab example..

 

My development enviroment is JBoss7.0.2.Final, Infinispan 5.1.0.CR1...can you help me for this ? Thanks.