{"action":"created","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5761","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5761/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5761/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5761/events","html_url":"https://github.com/hazelcast/hazelcast/issues/5761","id":96511840,"number":5761,"title":"Cache manager with custom classloader produces ClassNotFoundException when deserialize cache entry (OSGi env)","user":{"login":"exmortal","id":12248892,"avatar_url":"https://avatars.githubusercontent.com/u/12248892?v=3","gravatar_id":"","url":"https://api.github.com/users/exmortal","html_url":"https://github.com/exmortal","followers_url":"https://api.github.com/users/exmortal/followers","following_url":"https://api.github.com/users/exmortal/following{/other_user}","gists_url":"https://api.github.com/users/exmortal/gists{/gist_id}","starred_url":"https://api.github.com/users/exmortal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exmortal/subscriptions","organizations_url":"https://api.github.com/users/exmortal/orgs","repos_url":"https://api.github.com/users/exmortal/repos","events_url":"https://api.github.com/users/exmortal/events{/privacy}","received_events_url":"https://api.github.com/users/exmortal/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/PENDING","name":"PENDING","color":"bfe5bf"},{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Team:%20Integration","name":"Team: Integration","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"serkan-ozal","id":3143425,"avatar_url":"https://avatars.githubusercontent.com/u/3143425?v=3","gravatar_id":"","url":"https://api.github.com/users/serkan-ozal","html_url":"https://github.com/serkan-ozal","followers_url":"https://api.github.com/users/serkan-ozal/followers","following_url":"https://api.github.com/users/serkan-ozal/following{/other_user}","gists_url":"https://api.github.com/users/serkan-ozal/gists{/gist_id}","starred_url":"https://api.github.com/users/serkan-ozal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serkan-ozal/subscriptions","organizations_url":"https://api.github.com/users/serkan-ozal/orgs","repos_url":"https://api.github.com/users/serkan-ozal/repos","events_url":"https://api.github.com/users/serkan-ozal/events{/privacy}","received_events_url":"https://api.github.com/users/serkan-ozal/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-07-22T08:49:34Z","updated_at":"2015-08-03T11:10:58Z","closed_at":null,"body":"Hi,\r\n\r\nI found a strange situation with a cache manager classloader in OSGi environment (Apache KARAF container)\r\n\r\nI have 2 bundles. One of them contains hazelcast jar and takes care about cache manager initialization. (create and expose it via OSGi service method). Second one needs to get a cache instance from provider initialized in bundle1. Also it contains CacheItem class that should be used as a value type.\r\n\r\nHere is a test code: \r\n// get an instance of JSR107 cache provider created in bundle1\r\nCachingProvider provider = bundle1CacheProviderService.getProvider();\r\n// get an instance of cache manager for the bundle2 classloader\r\nCacheManager manager = provider.getCacheManager(bundle2ClassLoader, null);\r\n\r\n// create cache instance with empty configuration\r\nMutableConfiguration configuration = new MutableConfiguration<>();\r\nfinal Cache cache = manager.createCache(cacheName, configuration);\r\n\r\nCacheItem item1 = new CacheItem();\r\ncache.put(\"1\", item1); // OK\r\ncache.get(\"1\"); // ClassCastException. Dezerializer uses context classloader but not one I specified when create a cache manager.\r\n\r\nI have a quick look to the source code and found that manager classloader is used only for manager's identification by pair URI + classloader. Cache instances use a context classloader for deserialization.\r\n\r\nI know that if I use a own cache provider in each bundle will solve this issue, but I think that it will be a real overheat.\r\n\r\nI just want to know is it a bug or expected behavior.\r\n\r\nThanks,\r\n\r\nBR,\r\nVlad"},"comment":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/comments/127197238","html_url":"https://github.com/hazelcast/hazelcast/issues/5761#issuecomment-127197238","issue_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5761","id":127197238,"user":{"login":"serkan-ozal","id":3143425,"avatar_url":"https://avatars.githubusercontent.com/u/3143425?v=3","gravatar_id":"","url":"https://api.github.com/users/serkan-ozal","html_url":"https://github.com/serkan-ozal","followers_url":"https://api.github.com/users/serkan-ozal/followers","following_url":"https://api.github.com/users/serkan-ozal/following{/other_user}","gists_url":"https://api.github.com/users/serkan-ozal/gists{/gist_id}","starred_url":"https://api.github.com/users/serkan-ozal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serkan-ozal/subscriptions","organizations_url":"https://api.github.com/users/serkan-ozal/orgs","repos_url":"https://api.github.com/users/serkan-ozal/repos","events_url":"https://api.github.com/users/serkan-ozal/events{/privacy}","received_events_url":"https://api.github.com/users/serkan-ozal/received_events","type":"User","site_admin":false},"created_at":"2015-08-03T11:10:58Z","updated_at":"2015-08-03T11:10:58Z","body":"Hi @exmortal,\r\n\r\nCan you send the stacktrace?\r\nDoes the issue occurred while casting the returned object from `cache.get()` to a local variable like `CacheItem item = cache.get(\"1\");` or just `cache.get(\"1\");` itself causes `ClassCastException`?"}}