Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: OpenEntityManagerInViewFilter not working

  1. #11

    Default

    Yes, I removed the mvc:interceptors tag for avoiding conflicts, anyway thanks for the tip.

    I am using mvc:annotation-driven just for avoiding a full manual configuration, I am not sure if it could be a discouraged practice... So I am trying to look for the way of customizing the mvc:annotation-driven configuration. One option could be defining the RequestMappingHandlerMapping with the proper name according to the bean created by the mvc:annotation-driven, as you said; at the moment I wasn't able to find that bean name in the application's log using DEBUG and TRACE logging levels.

    Now I am looking for a solution like this: http://scottfrederick.blogspot.com/2...nnotation.html

    Any idea?

    Thanks.

  2. #12

    Default

    Well it seems that in cases of needing to customize the configuration provided by mvc:interceptors, it is recommended the usage of a BeanPostProcessor, I have read the same here: http://vard-lokkur.blogspot.com/2010...g-default.html

    What do you think Marten? Does it make sense for you?

    Thanks

    Regards.

  3. #13

    Default

    I didn't work neither, this was the set up:

    • Bean post processor's code:

    Code:
    package ie.i2e2.greenmode.web.configuration;
    
    import org.springframework.beans.BeansException;
    import org.springframework.beans.factory.config.BeanPostProcessor;
    import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor;
    import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
    
    public class MvcConfigurationPostProcessor implements BeanPostProcessor {
    
    	private OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor;
    	
    	@Override
    	public Object postProcessAfterInitialization(Object bean, String beanName)
    			throws BeansException {
    		if (bean instanceof RequestMappingHandlerMapping) {
    			Object [] interceptors = new Object [1];
    			interceptors [0] = openEntityManagerInViewInterceptor;
    			
    			((RequestMappingHandlerMapping) bean).setInterceptors(interceptors);
    		}
    		
    		return bean;
    	}
    
    	@Override
    	public Object postProcessBeforeInitialization(Object bean, String beanName)
    			throws BeansException {
    		return bean;
    	}
    
    	public OpenEntityManagerInViewInterceptor getOpenEntityManagerInViewInterceptor() {
    		return openEntityManagerInViewInterceptor;
    	}
    	public void setOpenEntityManagerInViewInterceptor(
    			OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor) {
    		this.openEntityManagerInViewInterceptor = openEntityManagerInViewInterceptor;
    	}
    
    }
    • Corresponding Spring configuration:

    Code:
    	<bean id="openEntityManagerInViewInterceptor" class="org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    	</bean>
    	
    	<bean id="mvcConfigurationPostProcessor" class="ie.i2e2.greenmode.web.configuration.MvcConfigurationPostProcessor">
    		<property name="openEntityManagerInViewInterceptor" ref="openEntityManagerInViewInterceptor" />
    	</bean>
    At the moment I give up, I cannot spend more time on this...

    If anybody has any clue please make me know, thank you for your help Marten.

    Regards.

Tags for this Thread

Posting Permissions

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