surinder-insonix / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

java.lang.IllegalArgumentException: can't accept class org.datanucleus.identity.IdentityReference as a memcache entity #163

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I receive the following exception when using JPA and having GAE memcache 
as L2 cache in datanucleus enabled (through javax.cache)

ava.lang.IllegalArgumentException: can't accept class 
org.datanucleus.identity.IdentityReference as a memcache entity
     at com.google.appengine.api.memcache.MemcacheSerialization.serialize
(MemcacheSerialization.java:262)
     at com.google.appengine.api.memcache.MemcacheSerialization.makePbKey
(MemcacheSerialization.java:199)
     at com.google.appengine.api.memcache.MemcacheServiceImpl.get
(MemcacheServiceImpl.java:226)
     at com.google.appengine.api.memcache.stdimpl.GCache.remove
(GCache.java:174)
     at org.datanucleus.cache.javaxcache.JavaxCacheLevel2Cache.evict
(JavaxCacheLevel2Cache.java:192)
     at org.datanucleus.ObjectManagerImpl.performLevel2CacheUpdateAtCommit
(ObjectManagerImpl.java:2982)
     at org.datanucleus.ObjectManagerImpl.preCommit
(ObjectManagerImpl.java:2925)
     at org.datanucleus.TransactionImpl.internalPreCommit
(TransactionImpl.java:369)
     at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:256)
     at org.datanucleus.jpa.EntityTransactionImpl.commit
(EntityTransactionImpl.java:104)
     at MyClass.storeB(MyClass.java:347)

please find the code of storeB() below:

    public B storeB(B b, String aKey) {
        EntityTransaction tx = em.getTransaction();
        tx.begin();
        try {
            A a = em.find(A.class, aKey);
            a.getBs().add(b);
            b.setA(a);
            em.merge(a);
            tx.commit();
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
        }
        return b;

    }

According to the stacktrace the exception is throws when doing tx.commit().

thanks in advance for your help

Original issue reported on code.google.com by andr.m...@gmail.com on 21 Nov 2009 at 3:01

GoogleCodeExporter commented 8 years ago
Interesting.  I believe the problem is that datanucleus is attempting to add 
the new
B instance to the L2 cache before its internal object id has been assigned.  As 
a
result, a "temporary" internal object id is constructed, which is really just a
wrapper around the object itself that implements hashCode() using
System.identityHashCode() and equals() using reference compare.  This wrapper 
is not
Serializable, so memcache rejects it.

Original comment by max.r...@gmail.com on 27 Nov 2009 at 11:23

GoogleCodeExporter commented 8 years ago
Even with NUCCORE-540 "fixed", this issue is still around -- see additional 
comments:
* http://www.datanucleus.org/servlet/jira/browse/NUCCORE-540

Original comment by ales.justin on 17 Aug 2010 at 2:24

GoogleCodeExporter commented 8 years ago
"The issue is still around". Well no testcase was ever provided for that, so 
the onus is on the user to demonstrate that the issue is around in DataNucleus 
code. If you provide one then it will be looked at.

Original comment by googleco...@yahoo.co.uk on 18 Jul 2011 at 4:52

GoogleCodeExporter commented 8 years ago
Not reproduceable currently, so downgrading

Original comment by googleco...@yahoo.co.uk on 21 Sep 2011 at 3:59

GoogleCodeExporter commented 8 years ago
Can't reproduce (with SVN trunk, and that uses DN 3.0 that has a completely 
rewritten L2 cache). Provide a complete testcase and it could be moved forward

Original comment by googleco...@yahoo.co.uk on 1 Nov 2011 at 4:25