Announcement Announcement Module
No announcement yet.
Superclass injected logicfacade is null Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Superclass injected logicfacade is null

    I have the following problem:

    Controller A has a onSubmit(...)-method which is intercepted with a class that is supposed to send mail.

    A also inherits B which exposes getLogic() and setLogic(..). the 'logic' property is wired in ordinary fashion using IoC. When unintercepted, the class works great, bu when the interceptor is put in action, getLogic() suddenly returns null.

    As a result of A not implementing any interface that declares 'onSubmit(..)', I've found out that you can make CGLIB proxy the class intercepted.
    (well, at least if you deside to break the 'protected'-scheme of the method that should fire the aspect and change it to 'public')

    Has anyone heard of sudden null-propertys when a CGLIB-proxy is used?

    The inetrceptor in its trial state:

    public class AfterSubmitNotificationInterceptor implements MethodInterceptor {
    	public static Logger log = Logger.getLogger(AfterSubmitNotificationInterceptor.class.getName());
    	private SimpleMimeMailHandler mailer;
    	public SimpleMimeMailHandler getMailer() { return (this.mailer); }
    	public void setMailer(SimpleMimeMailHandler mailer) { this.mailer = mailer; }
    	public Object invoke(MethodInvocation i) throws Throwable{
    		log.debug("AfterSubmitNotificationInterceptor invoked");
    		return i.proceed();
    The IoC-wiring of AOP....

    <bean id="notificationInjectorProxy" class="org.springframework.aop.framework.ProxyFactoryBean">		
    		<!--property name="proxyInterfaces"><value>org.springframework.web.servlet.mvc.Controller</value></property-->
    		<property name="proxyTargetClass"><value>true</value></property>
    		<property name="target"><ref local="newReportForm"/></property>
    		<property name="interceptorNames">
    	<bean id="notificationInjector" class="">
    		<property name="mailer"><ref local="notificationMimeMailer"/></property>
    	<bean id="notificationMimeMailer" class="ks.rah.avik2.logic.mail.SimpleMimeMailHandlerImpl">
    		<property name="sender"><ref local="sender"/></property>
    		<property name="preparator"><ref local="simpleMailPreparator"/></property>
    		<!--property name="message"><ref local="notificationMessage"/></property-->
    	<bean id="notificationInjectorPointcut" class="">
    		<property name="advice"><ref local="notificationInjector"/></property>
    		<property name="patterns">
    I've also tried to put getLogic() etc. as local members of A, but this still leaves 'logic' as null. Its superclass implements initializingBean, and no trouble there. Also everything works ok when I remove interception above on A:s onSubmit(...)-call.

    Anybody heard about this?

  • #2
    Maybe this issue helps.


    • #3
      It most certainly does. Glad it isn't me who's stupid. :lol: Thanks!
      This issue is very unfortunate. It forces you to make dummy interfaces just to be able to use JDK proxying as the CGLIB-way won't work, interfaces that describe basic Spring controller implementation...hmm.


      • #4
        I'm sure the bug will be fixed in the future - as far as I see it's about an intialization flag that has to be set in order to prevent overwriting. I am also pro-Cglib as I don't like making dummy interfaces (even though I find them useful and I know they are a recommended way of programming).