Announcement Announcement Module
No announcement yet.
Newbie question about configuration of a ProxyFactoryBean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie question about configuration of a ProxyFactoryBean

    I want to know how to get access to methods in an implementation class via her interface with the utilisation of a ProxyFactoryBean.

    I have an interface - BusinessDelegate - an her implementation class - BusinessdelegateImpl -. An Action class - BaseAction - from the web layer (using Struts) want to have access to a specific method from the interface - BusinessDelegate.

    public interface BusinessDelegate
    public void test();

    /*BusinessDelegate Implementation*/
    public class BusinessDelegateImpl implements BusinessDelegate
    public void test()

    /*The action class*/
    public abstract class BaseAction extends Action
    private BusinessDelegate businessDelegate;
    public void setServlet(ActionServlet actionServlet) {
    ServletContext servletContext = actionServlet.getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicati onContext(servletContext);
    this.businessDelegate = (BusinessDelegate) wac.getBean("businessBean");

    public BusinessDelegate getBusinessDelegate() {
    return businessDelegate;

    and finally the applicationContext.xml
    <bean id="businessBean" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value> egate</value>
    <property name="target">
    <ref local="beanTarget"/>

    <bean id="beanTarget" class=" egateImpl"/>


    When I reach the "this.businessDelegate.test();" in the BaseAction class, I received well kind message that said:
    AOP configuration seems to be invalid: tried calling public abstract void est() on [ [email protected]]: java.lang.IllegalArgumentException: object is not an instance of declaring class vokeJoinpointUsingReflection( )
    org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
    $Proxy0.test(Unknown Source) t(
    org.apache.struts.action.RequestProcessor.processA ctionCreate(
    javax.servlet.http.HttpServlet.service(HttpServlet .java:763)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


    What's the problem and how can have access to my business method test ?

    I'm using :
    Tomcat 5.0.19
    Spring 1.0.2
    Struts 1.1


  • #2
    Will try to investigate more later, but I can say now that there doesn't seem to be anything wrong with your proxy beans and config. I pretty much cut and paste to a small Spring 1.0.2 application test which called the Proxy just fine. It must have something to do with your particular usage or environment.


    • #3
      Config looks OK. Like Tim, I'm puzzled at this point. Are you sure that both BusinessDelegate and BusinessDelegateImpl are loaded by the same class loader?

      Have you tried invoking the proxy using a test case that loads the context, but doesn't involve a web app and the rest of your config?


      • #4
        AOPUtils is invoking using reflection.

        From javadocs for java.lang.reflect.Method we've got IllegalArgumentException if:
        1) the method is an instance method and the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof)
        2) if the number of actual and formal parameters differ
        3) if an unwrapping conversion for primitive arguments fails
        3) after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion

        None of these seem to be the case. Can you isolate the code and post just the minimal code that exhibits the behaviour?


        • #5
          Have you tried invoking the proxy using a test case that loads the context
          This worked for me.
          Are you sure that both BusinessDelegate and BusinessDelegateImpl are loaded by the same class loader
          I tried this. Moving both or just the implementation class to Tomcat's ${CATALINA_HOME}/shared/classes worked OK. Moving only the Interface on here causes a NoClassDefFoundError as expected.