Announcement Announcement Module
Collapse
No announcement yet.
Cannot apply AOP to JFrame Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot apply AOP to JFrame

    Hi. I do have to wrap a JFrame but get the following exception.

    Exception in thread "main" java.lang.IllegalAccessError: class javax.swing.$Proxy0 cannot access its superinterface javax.swing.TransferHandler$HasGetTransferHandler
    at java.lang.reflect.Proxy.defineClass0(Native Method)
    at java.lang.reflect.Proxy.getProxyClass(Proxy.java:5 04)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.jav a:581)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.getProxy(JdkDynamicAopProxy.java:117)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.getProxy(JdkDynamicAopProxy.java:108)
    at org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:97)
    at at.sozvers.Runner.main(Runner.java:20)

    Here the code that caused the Error.

    JFrame frame = new JFrame();
    ProxyFactory proxyFactory = new ProxyFactory(frame);
    proxyFactory.getProxy();


    Can anyone explain that behaviour?
    More important, what could I try to get around that problem?

    AG WW
    Last edited by wwan; Apr 24th, 2009, 08:39 AM.

  • #2
    Added the source that caused my problem

    Added the source that caused my problem

    Comment


    • #3
      Is solved
      Details see http://jira.springsource.org/browse/SPR-5708

      Comment


      • #4
        Possibly the same issue?

        Hi,

        I am trying to add aspect LTW to our application, and I get a similar exception to the one reported here:

        Code:
        Caused by: java.lang.IllegalAccessError: class com.mycomp.config.ConfigServiceImpl cannot access its superinterface com.mycomp.config.ConfigService
        at java.lang.ClassLoader.defineClass1(Native Method)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
        	at org.springframework.context.support.ContextTypeMatchClassLoader$ContextOverridingClassLoader.loadClassForOverriding(ContextTypeMatchClassLoader.java:106)
        	at org.springframework.core.OverridingClassLoader.loadClass(OverridingClassLoader.java:60)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        	at java.lang.ClassLoader.defineClass1(Native Method)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
        	at org.springframework.context.support.ContextTypeMatchClassLoader$ContextOverridingClassLoader.loadClassForOverriding(ContextTypeMatchClassLoader.java:106)
        	at org.springframework.core.OverridingClassLoader.loadClass(OverridingClassLoader.java:60)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        	at java.lang.ClassLoader.defineClass1(Native Method)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
        	at org.springframework.context.support.ContextTypeMatchClassLoader$ContextOverridingClassLoader.loadClassForOverriding(ContextTypeMatchClassLoader.java:106)
        	at org.springframework.core.OverridingClassLoader.loadClass(OverridingClassLoader.java:60)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        	at org.springframework.context.support.ContextTypeMatchClassLoader.loadClass(ContextTypeMatchClassLoader.java:62)
        	at org.springframework.util.ClassUtils.forName(ClassUtils.java:242)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1132)
        Both class and interface are non-public, as they are part of the package implementation and I don't want them exposed.

        The strange thing, is that this worked so far, and the exception only appeared once I added AspectJ LTW. Moreover, i added LTW for dependency-injection to Hibernate managed entities, and the failing class is not an entity (it is not annotated with @Configurable).

        I further tried to exclude the problematic class and interface from the aspectj weaver, via adding this to my aop.XML file:

        Code:
        <weaver options="-showWeaveInfo">
            <include within="com.mycompany.entities.*" />
            <exclude within="com.mycompany.config.*"/>
          </weaver>
        
          <aspects>
            <aspect name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect" />
        
          </aspects>
        It seems that once I replaced the default class-loader with the special classLoader that supports instrumentation, I am now forced to make all my non-public interfaces public.

        I also looked at the JIRA issue, but there is not enough information in there to understand what is to be expected. Is this a bug, a limitation? is there a work-around?

        Thanks,
        Naaman

        Comment

        Working...
        X