Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot wrap JFrame for AOP [SPR-5708] #10378

Closed
spring-projects-issues opened this issue May 1, 2009 · 6 comments
Closed

Cannot wrap JFrame for AOP [SPR-5708] #10378

spring-projects-issues opened this issue May 1, 2009 · 6 comments

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 1, 2009

Wolfgang Wagner opened SPR-5708 and commented

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();


Affects: 2.5.6

Reference URL: http://forum.springsource.org/showthread.php?t=70859

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 4, 2009

Juergen Hoeller commented

Thanks for reporting this! We're excluding non-public interfaces when autodetecting proxy interfaces now. This is the best we can do in such a case...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 5, 2009

Juergen Hoeller commented

Reopening this for RC1, since the matter is unfortunately not as trivial as it seemed. Non-public interfaces do work to some degree, but not in 'special' arrangements as with the JFrame class. We'll revisit this for Spring 3.0 RC1.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 7, 2009

Juergen Hoeller commented

There doesn't seem to be a compelling default algorithm for handling such 'special' non-public interfaces. I would suggest specifying the proxy interface(s) on the ProxyFactory instead, not relying on default detection of all implemented interfaces in such a case.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 18, 2009

Assaf Urieli commented

I made a silly mistake which is probably worth commenting here, in case others make it.
I put the jar containing the class I wanted to proxy into tomcat's shared/lib directory instead of directly into the webapp's WEB-INF/lib directory.
This resulted in the exact error described above on JdkDynamicAopProxy
Putting the jar into the WEB-INF/lib directory solved the problem. Might be useful to somebody else tearing their hair out!

Rgds,
Assaf

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Apr 13, 2010

Ulusses Gargamel commented

I do not understand the suggestion

"I would suggest specifying the proxy interface(s) on the ProxyFactory instead, not relying on default detection of all implemented interfaces in such a case."

I describe my problem at http://forum.springsource.org/showthread.php?t=87654

Basically I have a bunch of JDialog/JFrame beans which I want to add aspects to, using JDK proxies. This problem prevents me from doing it. I don't understand how I would specify ... on ProxyFactory etc, I define beans and then add aspects to them aop:aspectj-autoproxy. Is there some workaround I can use?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 1, 2010

Swapnil Joshi commented

I am having a similar problem mentioned by Ulusses Gargamel. Using CGLib proxies(i.e putting proxy-target-class="true" in aop:aspectj-autoproxy tag ) instead of JDK proxies doesn't solve the problem either.I need to add aspects to my JFrame/JDialog beans using JDK proxies.Juergen, could you please put some more light on the suggestion you mentioned? or is there any other way to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants