Announcement Announcement Module
No announcement yet.
Using a dynamic proxy as the command class Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a dynamic proxy as the command class

    I want to use a dynamic proxy as my controller's command class but i get the following error:

    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy160] to required type [
    java.lang.Class] for property 'commandClass'

    The reason I am doing this is because I have 2 interfaces to one implementation class, since I want to use 1 interface when using the class internally and the other when exposing the class in the API. I find that using a dynamic proxy will solve this problem for me.

    My spring configuration are as follows:

    The definition of the proxy is as follows:

    <bean id="jobTarget" class=""/>
        <bean id="job" class="org.springframework.aop.framework.ProxyFactoryBean">
            <property name="proxyInterfaces">
            <property name="target">
                <ref local="jobTarget"/>
    and the controller is as follows:

    <bean id="submissionController" class="com.bsd.webapp.action.submission.DEXSubmissionController" singleton="false">
            <property name="commandName">
            <property name="commandClass">
                <ref bean="job"/>
            <property name="formView">
            <property name="successView">
            <property name="sessionForm">
            <property name="validators">
                    <ref local="beanValidator"/>
                    <ref local="submissionValidator"/>

  • #2
    Don't supply the commandClass. The controller will use this setting to construct a new form. You will also need to override createForm and return the proxy.

    I would (doesn't mean its correct ) pass in the factory that creates the proxy to the controller, and then on createForm return a new instance from that factory.