Announcement Announcement Module
Collapse
No announcement yet.
coercion error with jsf - proxy fails isAssignableFrom Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • coercion error with jsf - proxy fails isAssignableFrom

    i am building a webapp with the myfaces jsf-implementation and use springs DelegatingVariableResolver to inject dependencies into jsf-managed beans. the spring version used is 2.0.1. when i use the @Transactional annotation in one of the injected services, spring has to create an aop proxy for this service class. With this proxy the method coerceToObject in the Coercions class of the commons-el package fails, because
    Code:
    pClass.isAssignableFrom (pValue.getClass ())
    returns false, if pValue holds a reference to the proxy instead of the actual class.
    I am sure i must be missing something basic, because spring and myfaces should be a fairly common combination, and i found nothing related to my problem on the internet.

    in faces-config.xml i have:
    Code:
    ...
    <managed-bean>
    		<managed-bean-name>editProjectForm</managed-bean-name> <managed-bean-class>org.bugwatch.webui.EditProjectForm</managed-bean-class>
    		<managed-bean-scope>request</managed-bean-scope>
    		<managed-property>
        		<property-name>storeProjectCommand</property-name>
        		<value>#{storeProjectCommand}</value>
      		</managed-property>
    </managed-bean>
    ...
    and in my applicationContext.xml:
    Code:
    ...
    <tx:annotation-driven/>
    ...
    <bean id="storeProjectCommand" class="org.bugwatch.service.StoreProjectCommand" scope="prototype">
       		<property name="projectDAO" ref="projectDAO" />
     	</bean>
    ...
    and this is the stacktrace when myfaces tries to initialize the managed bean:
    Code:
    javax.faces.FacesException: Cannot coerce $Proxy17 to org.bugwatch.service.StoreProjectCommand
    	at org.apache.myfaces.shared_impl.util.ClassUtils.convertToType(ClassUtils.java:308)
    	at org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:189)
    	at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:56)
    	at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:311)
    	at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:108)
    	at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:108)
    ...
    Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a value of type "$Proxy17" to type "org.bugwatch.service.StoreProjectCommand"
    	at org.apache.commons.el.Logger.logError(Logger.java:481)
    	at org.apache.commons.el.Logger.logError(Logger.java:498)
    	at org.apache.commons.el.Logger.logError(Logger.java:566)
    	at org.apache.commons.el.Coercions.coerceToObject(Coercions.java:799)
    ...
    Last edited by [email protected]; Dec 11th, 2006, 07:32 PM. Reason: spring version information

  • #2
    If your not programming to interfaces you might want to check this out, proxyTargetClass="true".

    http://www.cwinters.com/news/display/3410

    Also this might help.
    http://forum.springframework.org/showthread.php?t=28216

    Comment


    • #3
      great! it works! thank you so much.

      Comment

      Working...
      X