[ 
https://issues.apache.org/jira/browse/ARIES-1341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14610029#comment-14610029
 ] 

Michał Woś commented on ARIES-1341:
-----------------------------------

* only fields are scanned
I wanted to point that annotation target specifies 3 possibilities. As far as I 
know class level annotation means that a resource is injected when bean is 
initialized whereas two others when a resource is referenced (runtime)
* getAnnotation() return null because annotations are proxied (com.sun.proxy)
bean.getClass().getAnnotations() returns proxied objects so instances of 
com.sun.proxy.Proxy
that causes that if you call 
bean.getClass().getAnnotation(PersistenceContext.class) you will get null
you should call getAnnotations()[i].annotationType()
what's more it appears that classes are loaded by different class loaders so 
even if getAnnotations()[i].annotationType() equals PersistenceContext.class in 
terms of class names, it doesn't necessarily mean that 
getAnnotations()[i].annotationType() == PersistenceContext.class
*Setting persistence fields results in: Can not set 
javax.persistence.EntityManager field xxx to com.sun.proxy.$Proxy37
you are injecting proxies: EmSupplierProxy into persistence fields using 
reflection. this results in above exception.

I tested using java 8


> JpaBeanProcessor not working in karaf
> -------------------------------------
>
>                 Key: ARIES-1341
>                 URL: https://issues.apache.org/jira/browse/ARIES-1341
>             Project: Aries
>          Issue Type: Improvement
>          Components: Blueprint, JPA
>    Affects Versions: jpa-2.0.0
>         Environment: karaf-4.0.0, java 8
>            Reporter: Michał Woś
>            Assignee: Christian Schneider
>             Fix For: jpa-2.1.0, jpa-2.0.1
>
>
> * getAnnotation() return null because annotations are proxied (com.sun.proxy).
> * only top level class is scanned. super classes are not
> * only fields are scanned whereas target of persistence annotations is: TYPE, 
> METHOD, FIELD
> * Setting persistence fields results in:
> Can not set javax.persistence.EntityManager field xxx to 
> com.sun.proxy.$Proxy37



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to