Could not generate CGLIB subclass of class [class $Proxy0]
----------------------------------------------------------

                 Key: ORCHESTRA-12
                 URL: https://issues.apache.org/jira/browse/ORCHESTRA-12
             Project: MyFaces Orchestra
          Issue Type: Bug
          Components: Conversation
    Affects Versions: 1.0
            Reporter: Simon Kitching
            Assignee: Simon Kitching
             Fix For: 1.1


Orchestra generates a proxy for every orchestra-scoped bean in order to apply 
CurrentConversationAdvice, plus any other advices configured for the 
conversation. But this fails if something else has already proxied the bean 
using java.lang.reflect.Proxy, as that generates a final class that cglib 
cannot subclass.

This only happens in the following circumstances:
* aop:scoped-proxy is not being used,
* the bean has one or more spring advices on it (eg it has the @Transactional 
annotation on a method in the class), and
* the bean implements one or more interfaces.

The workaround for orchestra-1.0 users is just to attach aop:scoped-proxy to 
the bean definition.

The cause of the problem is that there can be the following chain of objects:
(1) the real bean
(2) a spring-generated proxy to hold advices to support things like 
transactional support.
(3) the orchestra-generated proxy to hold CurrentConversationAdvice and others
(4) the scoped proxy object

If (2) is created using java.lang.reflect.Proxy then (3) fails., because cglib 
tries to subclass the concrete type of (2), but that is a final type.

Object (2) only exists if there are advices that spring needs to attach. If 
there are none, then there is no problem as (3) proxies (1) directly.
Object (2) is always a CGLIB proxy if (4) is an aop:scoped-proxy object, as in 
that case the spring code that handles that pokes a magic value into the 
bean-definition for (1) that forces cglib to be used.
Object (2) is always a CGLIB proxy if bean (1) implements no interfaces.

But otherwise the problem occurs, and an exception occurs. Unfortunately it is 
quite common for a bean to implement interfaces and also have @Transactional, 
so this does occur frequently. For orchestra-1.0, using aop:scoped-proxy is 
recommended, though, so this isn't critical.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to