Announcement Announcement Module
Collapse
No announcement yet.
Problem configuring interceptors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem configuring interceptors

    Hi to all,

    I'm having a problem configuring my interceptors. I'm getting the following error (which doesn't explain a thing):

    Code:
    java.lang.IllegalArgumentException: Class must not be null
    This is the configuration code:

    Code:
    <bean id="library" class="org.springframework.aop.framework.ProxyFactoryBean">
    	<property name="proxyInterfaces">
    		<value>library.Service</value>
    	</property>
    	<property name="target">
    		<ref bean="libraryService"/>
    	</property>
    	<property name="interceptorNames">
    		<list>
    			<value>libraryServiceInterceptor</value>
    		</list>
    	</property>
    	
    </bean>
    
    <bean id="libraryServiceInterceptor" class="notifications.LibraryServiceInterceptor" />
     
    <bean id="corporate" class="org.springframework.aop.framework.ProxyFactoryBean">
    	<property name="proxyInterfaces">
    		<value>corporate.Service</value>
    	</property>
    	<property name="target">
    		<ref bean="corporateService"/>
    	</property>
    </bean>
    Any ideas what could be wrong?

    Thanks in advance.

  • #2
    Can you show a complete example of your configuration. The part you posted misses some referenced beans.

    We had the same issue and it had to do with the order the beans are loaded. Sometimes the ProxyFactoryBean gets created BEFORE the actual target is created. Weird case but it happens.

    Our solution was to create a ExtendProxyFactoryBean which had a constructor which took the target(Source) as a parameter. This appears to resolve the ordering issue. Notice that we had to place it inside the org.springframework.aop.framework package.

    Code:
    package org.springframework.aop.framework;
    
    import org.springframework.aop.TargetSource;
    
    /**
     * Workaround for Spring's initialization issues in combination with Spring 2.0 AOP.
     * Specifically placed in the org.springframework.aop.framework package because
     * it needs access to the package protected <code>targetSource</code> field to set it. 
     *
     */
    
    public class ExtendedProxyFactoryBean extends ProxyFactoryBean {
        
        public ExtendedProxyFactoryBean(TargetSource target) {
            super();
            this.targetSource=target;
        }
    }
    Some example configuration

    Code:
    <bean id="library" class="org.springframework.aop.framework.ExtendedProxyFactoryBean">
      <constructor-arg ref="libraryService"/> 
      <property name="proxyInterfaces">
        <value>library.Service</value>
      </property>
      <property name="interceptorNames">
        <list>
        	<value>libraryServiceInterceptor</value>
        </list>
      </property>
    </bean>
    Last edited by Marten Deinum; May 7th, 2007, 12:00 PM.

    Comment


    • #3
      The missing bean defenitions are out of the question, they worked before creating the interceptors. The approach you suggested patching spring in a way would be a backup solution for me, aren't there any other ways this problem can be solved? Thanks for your reply, I'll try it when no other solutions seem to be available.

      Comment


      • #4
        Originally posted by mdeinum View Post
        We had the same issue and it had to do with the order the beans are loaded. Sometimes the ProxyFactoryBean gets created BEFORE the actual target is created. Weird case but it happens.

        Our solution was to create a ExtendProxyFactoryBean which had a constructor which took the target(Source) as a parameter. This appears to resolve the ordering issue. Notice that we had to place it inside the org.springframework.aop.framework package.
        I had such problems with 2.0 Mx versions but not with the released ones. I worked around it by adding @depends="target" to the configuration of ProxyFactoryBean. This should at least make patching Spring superfluous.

        Example:
        Code:
        <bean id="corporate" depends="corporateService" class="org.springframework.aop.framework.ProxyFactoryBean">
        	<property name="proxyInterfaces">
        		<value>corporate.Service</value>
        	</property>
        	<property name="target">
        		<ref bean="corporateService"/>
        	</property>
        </bean>
        Jörg

        Comment


        • #5
          I tried using the depends-on attribute, but the same error keeps occuring. When starting the server, everything goes well, once I try to access the application, the error occurs.
          This is some relevant code:

          Code:
          <bean id="library" depends-on="libraryService" class="org.springframework.aop.framework.ProxyFactoryBean">
          	<property name="proxyInterfaces">
          		<value>library.Service</value>
          	</property>
          	<property name="target">
          		<ref bean="libraryService"/>
          	</property>
          	<!-- 
          	<property name="interceptorNames">
          		<list>
          			<value>libraryServiceInterceptor</value>
          		</list>
          	</property>	
          	-->
          </bean>
          
          <bean id="libraryService" class="libraryImpl.ServiceImpl">
          	<property name="properties">
          		<ref local="libraryProperties" />
          	</property>
          	<property name="DAO">
          		<ref local="libraryDao" />
          	</property>
          	<property name="corporateService">
          		<ref bean="corporateService" />
          	</property>
          </bean>
          
          <bean id="corporateService" class="corporateImpl.ServiceImpl">
          	<property name="DAO">
          		<ref local="corporateDao" />
          	</property>
          </bean>
          Anyone any ideas :s I removed some parts piece by piece to see which part was causing the problem, and it seems that the proxy 'library' causes the problem, also without setting the interceptor.

          What could be wrong here ?

          Comment


          • #6
            Can you post few lines of the stacktrace so that we can see where this IllegalArgumentException actually is thrown?

            Jörg

            Comment


            • #7
              Code:
              java.lang.IllegalArgumentException: Class must not be null
              	at org.springframework.util.Assert.notNull(Assert.java:113)
              	at org.springframework.util.ClassUtils.getQualifiedName(ClassUtils.java:289)
              	at org.springframework.util.ClassUtils.getShortName(ClassUtils.java:255)
              	at org.springframework.binding.method.MethodKey.parameterTypesString(MethodKey.java:243)
              	at org.springframework.binding.method.MethodKey.toString(MethodKey.java:233)
              	at java.lang.String.valueOf(Unknown Source)
              	at java.lang.StringBuffer.append(Unknown Source)
              	at org.springframework.binding.method.InvalidMethodKeyException.<init>(InvalidMethodKeyException.java:39)
              	at org.springframework.binding.method.MethodKey.resolveMethod(MethodKey.java:115)
              	at org.springframework.binding.method.MethodKey.getMethod(MethodKey.java:95)
              	at org.springframework.webflow.action.BeanInvokingActionFactory.createBeanInvokingAction(BeanInvokingActionFactory.java:88)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.parseBeanInvokingAction(XmlFlowBuilder.java:747)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.parseAnnotatedBeanInvokingAction(XmlFlowBuilder.java:737)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.parseAnnotatedActions(XmlFlowBuilder.java:700)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.parseRenderActions(XmlFlowBuilder.java:637)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.parseAndAddViewState(XmlFlowBuilder.java:597)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.parseAndAddStateDefinitions(XmlFlowBuilder.java:564)
              	at org.springframework.webflow.engine.builder.xml.XmlFlowBuilder.buildStates(XmlFlowBuilder.java:354)
              	at org.springframework.webflow.engine.builder.FlowAssembler.directAssembly(FlowAssembler.java:149)
              	at org.springframework.webflow.engine.builder.FlowAssembler.assembleFlow(FlowAssembler.java:131)
              	at org.springframework.webflow.engine.builder.RefreshableFlowDefinitionHolder.assembleFlow(RefreshableFlowDefinitionHolder.java:173)
              	at org.springframework.webflow.engine.builder.RefreshableFlowDefinitionHolder.getFlowDefinition(RefreshableFlowDefinitionHolder.java:93)
              	at org.springframework.webflow.definition.registry.FlowDefinitionRegistryImpl.getFlowDefinition(FlowDefinitionRegistryImpl.java:126)
              	at org.springframework.webflow.executor.FlowExecutorImpl.launch(FlowExecutorImpl.java:204)
              	at org.springframework.webflow.executor.support.FlowRequestHandler.handleFlowRequest(FlowRequestHandler.java:131)
              	at org.springframework.webflow.executor.mvc.FlowController.handleRequestInternal(FlowController.java:170)
              	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
              	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
              	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
              	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
              	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
              	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:350)
              	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
              	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at security.AuthorizationFilter.doFilter(AuthorizationFilter.java:80)
              	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at security.LoginFilter.doFilter(LoginFilter.java:152)
              	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
              	at security.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:26)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
              	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
              	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
              	at java.lang.Thread.run(Unknown Source)
              Thanks for the reply.

              Comment

              Working...
              X