3 Replies Latest reply on Jun 13, 2009 7:28 AM by Manik Surtani

    JNDI Deployment

    Matt Accola Newbie

      I posted a while back asking for advice on what was the best way to share a JBC instance for all applications on a node, http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151849. The recommendation was to use JNDI and I agree.

      However, I am running into the same problem that has been documented on other posts...org.jboss.cache.Cache is not Serilializable. When I try to bind a cache instance to JNDI in WebSphere 6.1 for example I get the following exception:

      A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
      Context implementation: com.ibm.ws.naming.jndicos.CNContextImpl
      Context method: bind
      Context name: HQ-M-3040Node01Cell/nodes/HQ-M-3040Node01/servers/server1
      Target name: fleetcycle/cache/jboss-cache
      Other data: Object to bind: org.jboss.cache.DataContainerImpl [0 nodes, 0 locks]
      Exception stack trace: com.ibm.ws.naming.util.CannotBindObjectException: Object is not of any type which can be bound.

      As described in the WebSphere 6.1 Info Center, http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.messages.doc/com.ibm.ws.naming.util.WsnMessages.html, this is because the object which is being bound is not Serializable.

      Here is the code (in progress) which is creating the cache instance and attempting to bind to JNDI.

       CacheFactory factory = new DefaultCacheFactory();
       Cache cache = factory.createCache(configFileName);
       InitialContext ctx = new InitialContext();
       ctx.bind("fleetcycle/cache/jboss-cache", cache);

      Is there any way to safely bind a JBC cache instance to JNDI?