I'm having an issue sharing objects between different JVMs and I would like to know if I'm doing something wrong.
Scenario
(serverA) Smartfox
(ServerB) Smartfox
(ServerC) GeronimoAppserver (or Tomcat, JBoss, Jetty, ...)
(ServerD) consoleApp
All servers are Terracotta clients.
How they work
The first server to connect to the cluster will fill a shared ROOT (e.g. a Map). For example, let's share a
Code: Select all
Map<String, Car> carMap = ConcurrentHashMap<String, Car>();Welcome to my classloader hell
It seems to be impossible to retrieve an item from a collection using serverA or serverB because their classloaders (both from Smartfox) are different than serverC (appServer):
SmartFoxServer ClassLoader: sun.misc.Launcher$AppClassLoader
Geronimo ClassLoader: org.apache.geronimo.kernel.config.MultiParentClassLoader
If I'm not wrong, Terracotta uses the entire object signature (i.e. namespace + Full Qualified Name) to store and share objects between different JVMs. And about that Map, guess what happens when I execute the following code on serverC:
Code: Select all
// model.Car
Car obj1 = new Car(); // line 1
Car obj2 = carMap.get("key1"); // line 2Code: Select all
...
Caused by: com.tc.exception.TCClassNotFoundException: java.lang.ClassNotFoundException: model.Car
at com.tc.object.ClientObjectManagerImpl.lookupOrCreateRoot(ClientObjectManagerImpl.java:651)
at com.tc.object.bytecode.ManagerImpl.lookupOrCreateRoot(ManagerImpl.java:370)
at com.tc.object.bytecode.ManagerImpl.lookupOrCreateRoot(ManagerImpl.java:349)
at com.tc.object.bytecode.ManagerUtil.lookupOrCreateRoot(ManagerUtil.java:151)
...Smartfox using a custom ClassLoaderClassCastException or ClassNotFoundException
These errors can be caused when differing clustered applications share object graphs but use different classloaders.
These errors can also be caused when a running web application is redeployed, such as when its container detects a change to a context file. Terracotta does not support "hot" redeployment of web applications.
We tried to adapt and use the MultiParentClassLoader, booting all classes (e.g. model.Car) shared between JVMs. The remaining classes (smartfox and libs) would be loaded by the parent classloader (sun.misc.Launcher$AppClassLoader). It didn't work.
So, the big question is: what I'm doing wrong? Any help will be greatly appreciated.
Cheers,
Fernando