today I ran into this problem which really bugs me, as almost the code already worked (and stopped working even after reverting to the older version).
I'm accessing a Spring-Bean on a Facelets-Page. Spring wraps these objects in Proxies to use aspects and some other stuff.
The problem is, that I get an exception when trying to access the property of a bean. The exception is something like this:
javax.el.PropertyNotFoundException: /customers.xhtml @23,27 value="#{customerBean.customer}": Property 'customer' not found on type $Proxy88
I know for sure (!!) that the according getter/setter methods are there. Things i tried so far:
Whatever I do, the class is somehow not correctly wrapped or not correctly loaded by the class-loader.
Has anybody an idea what could cause a problem like this? I don't know what to try additionally, so any advice is greatly appreciated!
Thanks in advance!
Regards, Robert
Spring AOP is proxy based. Spring used two types of proxy strategy one is JDK dynamic proxy and other one is CGLIB proxy. JDK dynamic proxy is available with the JDK. It can be only proxy by interface so target class needs to implement interface.
We create an instance of a proxy class for the specified interface that dispatches method invocations to the specified invocation handler, using newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) API method of Proxy. Then we invoke the method of the object.
Proxy is a structural design pattern that provides an object that acts as a substitute for a real service object used by a client. A proxy receives client requests, does some work (access control, caching, etc.) and then passes the request to a service object.
Dynamic proxies allow one single class with one single method to service multiple method calls to arbitrary classes with an arbitrary number of methods. A dynamic proxy can be thought of as a kind of Facade, but one that can pretend to be an implementation of any interface.
I also use Tomcat 7, JSF 2, Spring 3, Spring Security 3. I had same problems. Changing configuration of weaving didn't help.
My final solution was to add one line in to spring config:
<aop:aspectj-autoproxy proxy-target-class="true"/>
Jou need CGLIB on your classpath.
Hope this helps someone. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With