Java/JSF/Tomcat/Spring - Proxy-Object has different methods than original object

前提是你 提交于 2019-12-05 01:58:08

These errors usually occur if the load time weaving isn't properly configured. Make sure that you do not just configure a load time weaver, but that you also load the an appropriate java agent, or that the application server does that for you.

See the spring documentation for more information on how to configure this environment, e.g. chapter 7.8.4.6 Environment-specific configuration. Although, this covers the load time waving topic for AOP, it's the same configuration for other parts of spring that require load time weaving.

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. :)

OK, I found out how to manage method-security using AspectJ weaving.

You need to use at least Spring-security 3.0.5, you need to use right schemas in your spring-security.xml, at least:
http://www.springframework.org/schema/security/spring-security-3.0.5.xsd

You need to add spring-security-aspects as a dependency:

<dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-aspects</artifactId>             
   <version>3.0.5.RELEASE</version>
</dependency>

than you can add new attribute "mode" to your global-method security tag:

<global-method-security pre-post-annotations="enabled" mode="aspectj"/>

I think you also have to add to your standard Spring-configuration.xml, tag which enables AspectJ weaving:

<context:load-time-weaver aspectj-weaving="on"/>

And its also good to ged rid (remove) of the aop-proxy tag:

<aop:aspectj-autoproxy proxy-target-class="true"/>

Also it's better to use Spring-security 3.1.0 but than you also have to use at least Spring 3.0.7.

Hope this helps :)

Try to remove customerBean's domains which have got oneToMany fields.

I think your bean implemented Serializable. I ran into this today, the Serializable does something weird to the proxies, none of my methods were accessible. Get rid of the Serializable and it should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!