[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Sharing objects between JBoss process and non-JBoss process  XML
Forum Index -> Terracotta Platform
Author Message
shimi

journeyman

Joined: 02/18/2008 00:02:45
Messages: 12
Offline

Hello,

I am trying to write an example of a Master Worker application based on the article How to Build a POJO-based Data Grid using Open Terracotta by Jonas Bonér. Everything woks fine. I do have a problem when I am trying to run the same Master code with the same Terracota configuration file and boot jar inside JBoss AS and My Worker code as a simple Java application.

When my Worker gets the shared object from the queue, it crash with the following Exception:
Code:
 Exception in thread "Thread-10" com.tc.exception.TCClassNotFoundException: java.lang.ClassNotFoundException: No registered loader for description: JBoss.UnifiedClassLoader3:deploy/app-ee.ear, trying to load org.terracotta.datagrid.workmanager.routing.RoutableWorkItem
 	at com.tc.object.bytecode.ManagerUtil.lookupObject(ManagerUtil.java:335)
 	at java.util.concurrent.LinkedBlockingQueue$Node.getItem(LinkedBlockingQueue.java:65)
 	at java.util.concurrent.LinkedBlockingQueue.extract(LinkedBlockingQueue.java:139)
 	at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:386)
 	at org.terracotta.datagrid.workmanager.routing.RoutingAwareWorker.start(RoutingAwareWorker.java:46)
 	at com.shimi.example.StartRoutingWorker$1.run(StartRoutingWorker.java:20)
 Caused by: java.lang.ClassNotFoundException: No registered loader for description: JBoss.UnifiedClassLoader3:deploy/app-ee.ear, trying to load org.terracotta.datagrid.workmanager.routing.RoutableWorkItem
 	at com.tc.object.loaders.StandardClassProvider.getClassFor(StandardClassProvider.java:43)
 	at com.tc.object.ClientObjectManagerImpl.lookup(ClientObjectManagerImpl.java:522)
 	at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManagerImpl.java:423)
 	at com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManagerImpl.java:412)
 	at com.tc.object.bytecode.ManagerImpl.lookupObject(ManagerImpl.java:651)
 	at com.tc.object.bytecode.ManagerUtil.lookupObject(ManagerUtil.java:333)
 	... 5 more
 

it seems to me like it couldn't find the JBoss ClassLoader which does not exist in a simple Java program.

Is it possible to share objects between JBoss process and non-JBoss process?

I am using Terracota 2.5.1, JBoss 4.2.2 and Java sun 1.6.0.03
amiller

ophanim

Joined: 08/29/2007 09:05:48
Messages: 722
Location: St. Louis, MO
Offline

Hi,

Object identity in Terracotta is based on a combination of classloader name (a Terracotta concept) and object reference. The problem you are seeing is due to trying to share the same object across classloaders with different names.

One solution is to load the classes in your simple application using a custom classloader that sets it's name equal to that of the JBoss classloader. You can find sample code on a similar issue described in this post http://forums.terracotta.org/forums/posts/list/505.page.

You will need to replace the classloader name "com/caucho/loader/EnvironmentClassLoader" in that post's sample code with the appropriate name for your JBoss classloader. I'm not certain, but I think that may be the name in your stack trace: "JBoss.UnifiedClassLoader3:deploy/app-ee.ear". I'll have someone else double-check this.

FYI, we are investigating some better solutions for this use case for a future release.

Alex Miller (Terracotta Engineer) - Want to post to the forums? Sign up here
[WWW]
teck

seraphim
[Avatar]
Joined: 05/24/2006 15:03:25
Messages: 1128
Offline

For good measure, I'd also recommend making a call to set the thread context loader before the main class is loaded.

So before this line:
Code:
Class mainClass = loader.loadClass(args[0]);

Add a call like this:
Code:
Thread.currentThread().setContextClassLoader(loader);
 

Tim Eck (terracotta engineer)
shimi

journeyman

Joined: 02/18/2008 00:02:45
Messages: 12
Offline

Thanks, It solved the problem
shimi

journeyman

Joined: 02/18/2008 00:02:45
Messages: 12
Offline

nm
 
Forum Index -> Terracotta Platform
Go to:   
Powered by JForum 2.1.7 © JForum Team