Bug 284224 - IllegalAccessError with Hibernate Classes
Summary: IllegalAccessError with Hibernate Classes
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-22 01:54 EDT by PASTUREL CLA
Modified: 2009-07-23 05:51 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description PASTUREL CLA 2009-07-22 01:54:52 EDT
Opening a bug quite similar to fixed bug 253751, but with a Hibernate class ( not javax class).
I have the same issue with a Hibernate Class and a call pointcut.
I use AspectJ Version DEVELOPMENT released on Friday Jul 17, 2009.

And with LTW i get this exception (java.lang.IllegalAccessError at the end of the stack trace below) :
[WebappClassLoader@5060d5] weaveinfo Join point 'method-call(int
org.hibernate.type.ComponentType.getColumnSpan(org.hibernate.engine.Mapping))' in Type'org.hibernate.type.ComponentType' (ComponentType.java:618) advised by around advice
from 'iep.perf.aspects.abstractAspects.AbstractCPUDurationSimpleMethodWithParentImpl' (AbstractCPUDurationSimpleMethodWithParent.aj:80)
[WebappClassLoader@5060d5] weaveinfo Join point 'method-call(java.lang.Object[]
org.hibernate.type.ComponentType.getPropertyValues(java.lang.Object,
org.hibernate.EntityMode))' in Type 'org.hibernate.type.ComponentType'
(ComponentType.java:622) advised by around advice from 'iep.perf.aspects.abstractAspects.AbstractCPU DurationSimpleMethodWithParentImpl'(AbstractCPUDurationSimpleMethodWithParent.a
j:80)
[WebappClassLoader@5060d5] weaveinfo Join point 'method-call(boolean[]
org.hibernate.type.Type.toColumnNullness(java.lang.Object,
org.hibernate.engine.Mapping))' in Type 'org.hibernate.type.ComponentType' ComponentType.java:625) advised by around advice from
'iep.perf.aspects.abstractAspects.AbstractCPUDurationSimpleMethodWithParentImpl' (AbstractCPUDurationSimpleMethodWithParent.aj:80)
[WebappClassLoader@5060d5] debug generating class 'org.hibernate.type.ComponentT
ype$AjcClosure1'
[WebappClassLoader@5060d5] debug generating class'org.hibernate.type.ComponentType$AjcClosure3'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure5'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure7'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure9'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure11'

....

[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure241'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure243'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure245'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure247'
[WebappClassLoader@5060d5] debug generating class
'org.hibernate.type.ComponentType$AjcClosure249'
Initial SessionFactory creation failed. java.lang.IllegalAccessError: tried to
access class org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping
from class org.hibernate.type.ComponentType
[JClassLoader@1551b0] debug weaving 'org.apache.log4j.spi.ThrowableInformation'
Comment 1 Andrew Clement CLA 2009-07-22 13:23:49 EDT
So, from the error:

IllegalAccessError: tried to access class org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping from class org.hibernate.type.ComponentType


So whatever the advice did caused this attempt to access ComponentEntityModeToTuplizerMapping.  We need to check the visibility of that class.  From a quick google it looks to have default (package) visibility - and so cannot be seen from org.hibernate.type.ComponentType.  This means in order for AspectJ to do its job, it must be able to modify the visibility of ComponentEntityModeToTuplizerMapping.  Are you definetly including that type as something the load time weaver can see and not excluding it in your aop.xml?
Comment 2 PASTUREL CLA 2009-07-23 03:02:16 EDT
Thanks Andy for the answer.
Effectively the class  org.hibernate.type.ComponentType has a protected attribute  org.hibernate.tuple.component.EntityModeToTuplizerMapping.

The ComponentType was not excluded in the file aop.xml. Excluding it in the tag <weaver> solves the problem.

This is not a bug. Sorry.

I am going to try if a privileged aspect allows the access to the protected attribute.

So you can close the bug

Comment 3 PASTUREL CLA 2009-07-23 05:51:47 EDT
For information:
making the aspect privileged  doesn't solve my problem with Hibernate.
Perhaps is-it due to the mecanism of dynamic proxy used by Hibernate ( javassist that is a weaver also as i understand) ?

So the good way is to exclude the caller class from the weaver.