[jboss-user] [JBossCache] - Re: Strange ClassCastException in OptimisticCreateIfNotExist

spennec do-not-reply at jboss.com
Wed Nov 7 05:25:26 EST 2007


I changed a few things and might have moved a bit forward....

The ClassCast with my class happened with the put being done this way:


  | final InvocationContext invocationContext = treeCache.getInvocationContext();
  | final Option optionOverrides = invocationContext.getOptionOverrides();
  | optionOverrides.setCacheModeLocal(localMode);
  | treeCache.put(fqn, ITEM, map);
  | 

... with ITEM being a static final String named "item" just to bind a key to the map.

Now I have a class cast, but not on my class. The ClassCast is as follows:


  | java.lang.ClassCastException: java.lang.String
  |  at org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor.invoke(OptimisticCreateIfNotExistsInterceptor.java:57)
  |  at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  |  at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.invoke(OptimisticValidatorInterceptor.java:67)
  |  at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  |  at org.jboss.cache.interceptors.OptimisticLockingInterceptor.invoke(OptimisticLockingInterceptor.java:99)
  | 
  | 

The only thing I changed is the way I put the data in treeCache. It is now done this way:


  | 
  | 
  | Node<String, Object> node = treeCache.getRoot().getChild(PF_CACHE_FQN);
  |         if (node == null) {
  |             node = treeCache.getRoot().addChild(fqn);
  |             if (logger.isDebugEnabled()) {
  |                 logger.debug("Added cache child: " + fqn);
  |             }
  |         }
  | 
  | final InvocationContext invocationContext = treeCache.getInvocationContext();
  | final Option optionOverrides = invocationContext.getOptionOverrides();
  | optionOverrides.setCacheModeLocal(localMode);
  | node.put(PF_CACHE_NAME, portfolioCache);
  | 

... with PF_CACHE_FQN being a Fqn object to describe the node, and PF_CACHE_NAME being a String that is used as a key to bind the map.

Does it help you understand what's going wrong??

Thanks a lot for your help!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102456#4102456

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102456



More information about the jboss-user mailing list