1 Reply Latest reply on Aug 18, 2011 11:00 AM by Vinicius Carvalho

    JBoss AS 7 - JNDI example not working

    Vinicius Carvalho Apprentice

      Hi, I'm trying to follow the example from the site but it's not working:

       

       

      @Path("/infinispan")
      @ApplicationScoped
      public class InfinispanCache {
      
      
        @Resource(lookup="java:jboss/infinispan/ClusterCache")
        private CacheContainer container;
      
        private Cache cache;
      
        @PostConstruct
        public void warm(){
        this.cache = container.getCache();
        }
      
        
        @POST
        @Path("/{key}")
        public void put(@PathParam(value="key") String key,@QueryParam(value="value") String value){
        this.cache.put(key, value);
        }
      
        @GET
        @Path("/{key}")
        @Produces("text/plain")
        public String get(@PathParam(value="key") String key){
        return String.valueOf(this.cache.get(key));
        }
        
      
      }
      
      

       

       

      My config:

       

       

       <cache-container name="ClusterCache" default-cache="default">
                          <alias>
                              ClusterCache
                          </alias>
                          <replicated-cache mode="SYNC" name="default" batching="true">
                              <locking isolation="REPEATABLE_READ"/>
                          </replicated-cache>
                      </cache-container>
      
      

       

       

      But when I try to access the cache:

       

      org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Error looking up java:comp/env/com.fb.cache.InfinispanCache/container in JNDI

      org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345)

      org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321)

      org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)

      org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)

      org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)

      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)

      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

      org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

      javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

       

      Tried to add jndi-name to the cache-container, tried to change the lookup, nothing seems to work. Is JNDI really supported on JBAS 7?