Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315854

Summary: CGLIB proxying using Wrapper Policy
Product: z_Archived Reporter: Gaurav Malhotra <gaurav.malhotra>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: blocker    
Priority: P2 CC: ilyes_bh, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Wrapper Policy (Latest) - Eclipse WorkSpace
none
CGLIB proxy using Wrapper policy - Final Working none

Description Gaurav Malhotra CLA 2010-06-04 18:43:26 EDT
Hi All, 
  I am trying to create a proxy around a JPA entity using EclipseLink WrapperPolicy. I am using CGLIB proxy. I am getting the following exception 
Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-7009] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.ValidationException 
Exception Description: Missing descriptor for [class readwrite.model.EmployeeAddress$$EnhancerByCGLIB$$b60b0c9b].  Verify that the descriptor has been properly registered with the Session. 
        at org.eclipse.persistence.exceptions.ValidationException.missingDescriptor(ValidationException.java:2159) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3836) 
        at org.eclipse.persistence.mappings.ObjectReferenceMapping.buildCloneForPartObject(ObjectReferenceMapping.java:68) 
        at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.cloneAttribute(NoIndirectionPolicy.java:72) 
        at org.eclipse.persistence.mappings.ForeignReferenceMapping.buildClone(ForeignReferenceMapping.java:172) 
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.populateAttributesForClone(ObjectBuilder.java:2684) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.populateAndRegisterObject(UnitOfWorkImpl.java:3640) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.java:984) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.java:893) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkIdentityMapAccessor.getAndCloneCacheKeyFromParent(UnitOfWorkIdentityMapAccessor.java:171) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkIdentityMapAccessor.getFromIdentityMap(UnitOfWorkIdentityMapAccessor.java:110) 
        at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.getFromIdentityMap(IdentityMapAccessor.java:331) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3884) 

I was able to solve the problem using the solution mentioned - 
http://old.nabble.com/CGLIB-Proxy-Using-Wrapper-Policy-to28780712.html#a28785834

I am also attaching my eclipse work space for reference.
Comment 1 Gaurav Malhotra CLA 2010-06-05 10:24:48 EDT
Created attachment 171195 [details]
Wrapper Policy (Latest) - Eclipse WorkSpace

Wrapper Policy (Latest) - Eclipse WorkSpace
Comment 2 Gaurav Malhotra CLA 2010-06-05 10:49:09 EDT
Also I would like to add, when we apply wrapper policy, the toplink-grid fails. The error can be reproduced by uncommenting @Customizer(CoherenceReadWriteCustomizer.class) in the entities in attached project.

1) Employee
2) EmployeeAddress
3) PhoneNumber

Scenario 1 to reproduce the exception
 1) Run StartCacheServer
 2) Run InsertExample
 3) Run WrapperPolicySample

Scenario 2 to reproduce the exception

 1) Run StartCacheServer
 2) Run CacheWarmEntities
 3) Run WrapperPolicySample

NOTE - Add CGLIB (and asm) + Ecliplink + coherence + toplink grid libs when running the project.
Comment 3 Gaurav Malhotra CLA 2010-06-05 14:55:21 EDT
Created attachment 171201 [details]
CGLIB proxy using Wrapper policy - Final Working

CGLIB proxy using WrapperPolicy is working. Please review my approach
Comment 4 Tom Ware CLA 2010-06-14 14:27:04 EDT
Setting target and priority.  See the following page for details of what these fields mean:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 5 Ilyes Ben Hassen CLA 2010-09-01 09:17:28 EDT
(In reply to comment #4)
> Setting target and priority.  See the following page for details of what these
> fields mean:
> 
> http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Hi,
I would like to write on this bug instead of creating a new one since my matter is similar.
I would like to use one-to-one or/and many-to-one indirection (lazy loading) without depending on EclipseLink ValueHolderInterface or 
using the default JDK Proxy Indirection. 
I would suggest to transparently use 1:1 indirection using, for example, CGLIB.  Similar to ProxyIndirectionPolicy a CGLIBProxyIndirectionPolicy could be provided for that reason.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:09:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink