[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Ehcache problem TCNonPortableObjectError RMIAsynchronousCacheReplicator.replicationThread  XML
Forum Index -> General
Author Message
blackza

neo

Joined: 08/25/2008 00:58:07
Messages: 5
Offline

Hi, I'm trying to use ehcache with terracotta
I'm new to terracotta I just pass simple dso tutorial and then I next to ehcache tutorial then I got error

Code:
 init:
 deps-jar:
 compile:
 run:
 2551-08-25 15:01:20,616 INFO - Terracotta 2.6.2, as of 20080626-150612 (Revision 8952 by cruise@WXPMO0 from 2.6)
 2551-08-25 15:01:21,051 INFO - Configuration loaded from the file at 'D:\Work\project\terracotta\TestTerraCotta1\tc-config-example.xml'.
 2551-08-25 15:01:21,264 INFO - Log file: 'D:\Work\project\terracotta\TestTerraCotta1\logs-192.168.0.6\terracotta-client.log'.
 2551-08-25 15:01:26,473 INFO - Statistics buffer: 'D:\Work\project\terracotta\TestTerraCotta1\statistics-192.168.0.6'.
 com.tc.exception.TCNonPortableObjectError: 
 *******************************************************************************
 Attempt to share an instance of a non-portable class referenced by a portable class. This
 unshareable class is a subclass of a JVM- or host machine-specific resource. Please either
 modify the class hierarchy or ensure that instances of this class don't enter the shared object
 graph.
 
 For more information on this issue, please visit our Troubleshooting Guide at:
 http://terracotta.org/kit/troubleshooting
 
 Referring class             : net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator
 Referring field             : net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThread
 Thread                      : main
 JVM ID                      : VM(0)
 Unshareable superclass names: java.lang.Thread
 
 Action to take:
 
 1) Change your application code
    * Ensure that no instances of net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread
      nor any other subclass instances of the classes:
        java.lang.Thread
      are added to any shared object graph
 
    - OR -
 
 2) Mark the offending field as transient (and thus not shared)
    * edit your tc-config.xml file
    * locate the <dso> element
    * add this snippet inside the <dso> element, above the <locks> element
 
        <transient-fields>
          <field-name>null</field-name>
        </transient-fields>
 
    * if there is already a <transient-fields> element present, simply add
      the new field inside it
 
 
 *******************************************************************************
 
         at com.tc.object.ClientObjectManagerImpl.throwNonPortableException(ClientObjectManagerImpl.java:826)
         at com.tc.object.ClientObjectManagerImpl.checkPortabilityOfTraversedReference(ClientObjectManagerImpl.java:718)
         at com.tc.object.ClientObjectManagerImpl.access$900(ClientObjectManagerImpl.java:82)
         at com.tc.object.ClientObjectManagerImpl$NewObjectTraverseTest.checkPortability(ClientObjectManagerImpl.java:1059)
         at com.tc.object.Traverser.addReferencedObjects(Traverser.java:48)
         at com.tc.object.Traverser.traverse(Traverser.java:89)
         at com.tc.object.ClientObjectManagerImpl.addToManagedFromRoot(ClientObjectManagerImpl.java:982)
         at com.tc.object.ClientObjectManagerImpl.create(ClientObjectManagerImpl.java:338)
         at com.tc.object.ClientObjectManagerImpl.lookupOrCreateIfNecesary(ClientObjectManagerImpl.java:402)
         at com.tc.object.ClientObjectManagerImpl.lookupOrCreate(ClientObjectManagerImpl.java:375)
         at com.tc.object.tx.ClientTransactionManagerImpl.logicalInvoke(ClientTransactionManagerImpl.java:743)
         at com.tc.object.TCObjectLogical.logicalInvoke(TCObjectLogical.java:20)
         at com.tc.object.bytecode.ManagerImpl.logicalInvoke(ManagerImpl.java:235)
         at com.tc.object.bytecode.ManagerUtil.logicalInvoke(ManagerUtil.java:274)
         at java.util.HashMap.put(HashMap.java)
         at net.sf.ehcache.CacheManager.__tc_wrapped_addCacheNoCheck(CacheManager.java:640)
         at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java)
         at net.sf.ehcache.CacheManager.addConfiguredCaches(CacheManager.java:348)
         at net.sf.ehcache.CacheManager.__tc_wrapped_init(CacheManager.java:227)
         at net.sf.ehcache.CacheManager.init(CacheManager.java)
         at net.sf.ehcache.CacheManager.<init>(CacheManager.java:205)
         at net.sf.ehcache.CacheManager.create(CacheManager.java:374)
         at net.sf.ehcache.CacheManager.getInstance(CacheManager.java:395)
         at tutorial.cache.AlbumCacheManager.<init>(AlbumCacheManager.java:18)
         at tutorial.HelloWorld.main(HelloWorld.java:56)
 Exception in thread "main" com.tc.exception.TCNonPortableObjectError: 
 *******************************************************************************
 Attempt to share an instance of a non-portable class referenced by a portable class. This
 unshareable class is a subclass of a JVM- or host machine-specific resource. Please either
 modify the class hierarchy or ensure that instances of this class don't enter the shared object
 graph.
 
 For more information on this issue, please visit our Troubleshooting Guide at:
 http://terracotta.org/kit/troubleshooting
 
 Referring class             : net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator
 Referring field             : net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThread
 Thread                      : main
 JVM ID                      : VM(0)
 Unshareable superclass names: java.lang.Thread
 
 Action to take:
 
 1) Change your application code
    * Ensure that no instances of net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread
      nor any other subclass instances of the classes:
        java.lang.Thread
      are added to any shared object graph
 
    - OR -
 
 2) Mark the offending field as transient (and thus not shared)
    * edit your tc-config.xml file
    * locate the <dso> element
    * add this snippet inside the <dso> element, above the <locks> element
 
        <transient-fields>
          <field-name>null</field-name>
        </transient-fields>
 
    * if there is already a <transient-fields> element present, simply add
      the new field inside it
 
 
 *******************************************************************************
 
         at com.tc.object.ClientObjectManagerImpl.throwNonPortableException(ClientObjectManagerImpl.java:826)
         at com.tc.object.ClientObjectManagerImpl.checkPortabilityOfTraversedReference(ClientObjectManagerImpl.java:718)
         at com.tc.object.ClientObjectManagerImpl.access$900(ClientObjectManagerImpl.java:82)
         at com.tc.object.ClientObjectManagerImpl$NewObjectTraverseTest.checkPortability(ClientObjectManagerImpl.java:1059)
         at com.tc.object.Traverser.addReferencedObjects(Traverser.java:48)
         at com.tc.object.Traverser.traverse(Traverser.java:89)
         at com.tc.object.ClientObjectManagerImpl.addToManagedFromRoot(ClientObjectManagerImpl.java:982)
         at com.tc.object.ClientObjectManagerImpl.create(ClientObjectManagerImpl.java:338)
         at com.tc.object.ClientObjectManagerImpl.lookupOrCreateIfNecesary(ClientObjectManagerImpl.java:402)
         at com.tc.object.ClientObjectManagerImpl.lookupOrCreate(ClientObjectManagerImpl.java:375)
         at com.tc.object.tx.ClientTransactionManagerImpl.logicalInvoke(ClientTransactionManagerImpl.java:743)
         at com.tc.object.TCObjectLogical.logicalInvoke(TCObjectLogical.java:20)
         at com.tc.object.bytecode.ManagerImpl.logicalInvoke(ManagerImpl.java:235)
         at com.tc.object.bytecode.ManagerUtil.logicalInvoke(ManagerUtil.java:274)
         at java.util.HashMap.put(HashMap.java)
         at net.sf.ehcache.CacheManager.__tc_wrapped_addCacheNoCheck(CacheManager.java:640)
         at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java)
         at net.sf.ehcache.CacheManager.addConfiguredCaches(CacheManager.java:348)
         at net.sf.ehcache.CacheManager.__tc_wrapped_init(CacheManager.java:227)
         at net.sf.ehcache.CacheManager.init(CacheManager.java)
         at net.sf.ehcache.CacheManager.<init>(CacheManager.java:205)
         at net.sf.ehcache.CacheManager.create(CacheManager.java:374)
         at net.sf.ehcache.CacheManager.getInstance(CacheManager.java:395)
         at tutorial.cache.AlbumCacheManager.<init>(AlbumCacheManager.java:18)
         at tutorial.HelloWorld.main(HelloWorld.java:56)
 



this is tc-config.xml

Code:
 <?xml version="1.0" encoding="UTF-8"?>
 <tc:tc-config xmlns:tc="http://www.terracotta.org/config">
         <clients>
                 <modules>
                         <module group-id="org.terracotta.modules" name="tim-ehcache-1.3" version="1.1.3"/>
                         <module name="tim-ehcache-commons" version="1.1.3" />
                 </modules>
         </clients>
         <application>
                 <dso>
                         <!--transient-fields>
                                 <field-name>net.sf.ehcache.store.DiskStore.expiryThread</field-name>
                                 <field-name>net.sf.ehcache.store.DiskStore.spoolThread</field-name>
                                 <field-name>net.sf.ehcache.store.DiskStore.randomAccessFile</field-name>
                                 <field-name>net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThread</field-name>
                                 <field-name>net.sf.ehcache.CacheManager.cacheManagerEventListener</field-name>
                                 <field-name>net.sf.ehcache.CacheManager.cacheManagerPeerListener</field-name>
                                 <field-name>net.sf.ehcache.CacheManager.cacheManagerPeerProvider</field-name>
                         </transient-fields-->
                         <roots>
                                 <root>
                                         <field-name>tutorial.HelloWorld.hellos</field-name>
                                 </root>
                                 <root>
                                         <field-name>tutorial.HelloWorld.map</field-name>
                                 </root>
                                 <!--root>
                                         <field-name>tutorial.cache.AlbumCacheManager.manager</field-name>
                                 </root-->
                         </roots>
                         <locks>
                                 <autolock>
                                         <method-expression>* tutorial.HelloWorld*.*(..)</method-expression>
                                         <lock-level>write</lock-level>
                                 </autolock>
                         </locks>
                         <instrumented-classes>
                                 <include>
                                         <class-expression>tutorial.cache.AlbumCacheManager</class-expression>
                                 </include>
                                 <include>
                                         <class-expression>tutorial.model.Album</class-expression>
                                 </include>
                                 <include>
                                         <class-expression>tutorial.HelloWorld</class-expression>
                                 </include>
                         </instrumented-classes>
                 </dso>
         </application>
 </tc:tc-config>
 


this is main java code
Code:
 /*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
 package tutorial;
 
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import tutorial.cache.AlbumCacheManager;
 import tutorial.model.Album;
 
 /**
  *
  * @author White
  */
 public class HelloWorld {
 
         private final List hellos = new ArrayList();
 
         private final MyMap map = new MyMap();
 
         public void sayHello() {
                 synchronized(hellos) {
                         hellos.add("Hello, World " + new Date());
 
                         for(Iterator it = hellos.iterator(); it.hasNext();) {
                                 System.out.println(it.next());
                         }
                 }
         }
 
         public void addMap() {
                 synchronized(map) {
                         map.put(new Date());
                 }
         }
 
         public void showMap(int index) {
                 synchronized(map) {
                         for(String key : map.keySet()) {
                                 System.out.println("show " + key + " = " + map.
                                         get(key));
                         }
                 }
         }
 
         public static void main(String[] args) {
 //                new HelloWorld().sayHello();
 //
 //                new HelloWorld().addMap();
 //
 //                new HelloWorld().showMap(0);
                 AlbumCacheManager cache = new AlbumCacheManager();
                 findAlbums(cache);
                 loadAlbums(cache);
                 findAlbums(cache);
         }
 
         private static void loadAlbums(AlbumCacheManager cache) {
                 System.out.println();
                 System.out.println("Adding albums.");
                 cache.addAlbum(new Album(0, "Moving Pictures", "Rush", 1981));
                 cache.addAlbum(new Album(1, "What's Going On", "Marvin Gaye",
                         1971));
                 cache.addAlbum(new Album(2, "The White Album", "The Beatles",
                         1968));
                 cache.addAlbum(new Album(3, "The Dark Side of the Moon", "Pink Floyd", 1973));
 
         }
 
         private static void findAlbums(AlbumCacheManager cache) {
                 System.out.println();
                 System.out.println("Finding albums:");
                 for(int i = 0; i < 4; i++) {
                         System.out.println(cache.findAlbum(i));
                 }
         }
 
         class MyMap extends HashMap<String, Object> {
 
                 private int runningNumber = 0;
 
                 public Object put(Object value) {
 
                         return super.put(String.valueOf(runningNumber++), value);
                 }
         }
 }
 


*** Sorry, this class just mess up with two tutorial in one, but I think it should not be matter.

and then I found that if I add some transient-fields in config file my code works, but I think it not required to do so, right? no any mention about put these fields into config, I think I follow exact the way as the tutorial but it not works, what I do wrong?

I run tc server from TC_HOME/bin/start-tc-server.bat

then run client within netbeans with java options
-Xbootclasspath/p:"D:\Terracotta\terracotta-2.6.2\lib\dso-boot\dso-boot-hotspot_win32_160_07.jar" -Dtc.install-root="D:\Terracotta\terracotta-2.6.2" -Dtc.config=tc-config-example.xml
amiller

ophanim

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

I suspect you have a cacheEventListenerFactory configured in your ehcache.xml for cache replication. When using Terracotta, this is not needed as Terracotta handles the distributed cache replication. Can you either confirm or post your ehcache.xml?

You will need to remove the cacheEventListenerFactory from ehcache.xml when working with Terracotta.

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

neo

Joined: 08/25/2008 00:58:07
Messages: 5
Offline

Ahhh, thank you so much.
I really have cacheEventListenerFactory in config of other sample caches of ehcache.xml
it works now after I remove all of them except the default and the albumCache.
amiller

ophanim

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

I filed a jira ( http://jira.terracotta.org/jira/browse/FORGE-274 ) in our system to deal with this scenario in a less confusing manner. Thanks...

Alex Miller (Terracotta Engineer) - Want to post to the forums? Sign up here
[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.7 © JForum Team