Results 1 to 2 of 2

Thread: Spring AOP on JSF Managed Beans

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    1

    Default Spring AOP on JSF Managed Beans

    I am trying to apply Spring AOP on JSF Managed Beans, but for some reason as soon as I apply AOP JSF is throwing MethodNotFoundException.

    here is my code :
    Web.xml
    Code:
       	
       	<application>
       		<default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
       		<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>	
    	</application>
    applicationContext.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:security="http://www.springframework.org/schema/security"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
      
        <aop:aspectj-autoproxy/>
      	<bean id="loginAuditAspect" class="com.test.mobile.service.LoginAuditManagementAspect">
      		<constructor-arg index="0">
    			<list>
    				<bean class="com.test.mobile.service.LoginAuditableResourceResolver" />
    				<bean class="com.test.mobile.service.LoggedInAuditableResourceResolver" />
    				<bean class="com.test.mobile.service.NavigationAuditableResourceResolver" />
    			</list>
    		</constructor-arg>
    	</bean>
      
      <bean id="loginService" class="com.test.mobile.service.MLoginServiceImpl" />
      
        <bean id="memberService" class="com.test.mobile.service.MMemberServiceImpl" scope="session">
      		<property name="thpContext" ref="thpContext"></property>
        </bean> 
       
       <bean id="mMemberProfileBean" class="com.test.mobile.service.MMemberProfileBean" scope="session">
     	  <property name="memberService" ref="memberService"></property>
       </bean>
       
       <bean id="testBean" class="com.test.mobile.service.TestBean" scope="session">
       </bean>
      </beans>
    Backing Bean:

    Code:
    public class TestBean extends BaseBackingBean {
    
    	private static final long serialVersionUID = 1L;
    	
    	
    @Auditable(resourceName="LoggedIn", resourceResolverClass=com.test.mobile.service.LoggedInAuditableResourceResolver.class)
    	public String getXxx() {
    		System.out.println("entered populateMemberProfile.............TestNBean.....");
    		return null;
    	}
    
    }

    Can someone help me in applying AOP logic on JSF managed beans

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    If it is a JSF managed bean it will not work as spring cannot apply AOP to beans it doesn't manage. So basically what you have isn't a JSF managed bean but merely a spring bean which is accessed by JSF.

    You haven't posted your other classes but I suspect that your BaseBackingBean implements several interfaces and spring uses JDK dynamic proxies which means only methods available on the interfaces are available... Switch to either loadtimeweaving or class based proxied.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •