PDA

View Full Version : Getting Spring and XWork to work together (w/advised actions


sutter2k
Aug 25th, 2004, 01:21 PM
Below is the email from the opensymphony mailing list.

I am trying to wrap/advise XWork actions and declare transaction handling around them. Transaction handling works fine.....for a little while at least. After a while the classes seem to be mutating.


Is this a cglib problem? Why would class instances start mutating?


--------------------------------------------------------------------------------
From: Jason Carreira [mailto:jason.carreira@notiva.com]
Sent: Wednesday, August 25, 2004 1:07 PM
To: dev@webwork.dev.java.net
Subject: RE: [OS-webwork] XWork/Spring work yet?


Hmm... The problem is that it caches the Method object to execute against subsequent instances of the Action class... It appears that the Class of these instances is changing at some point.. I guess we'll need to implement the change suggested to check the Class to see if it has changed and dump the cached Method object... This is a bug with Spring, so if you can get them to fix this, that would be even better.

Jason
-----Original Message-----
From: Matthew Payne [mailto:matthew.payne@ins.com]
Sent: Wednesday, August 25, 2004 12:31 PM
To: dev@webwork.dev.java.net
Subject: [OS-webwork] XWork/Spring work yet?


What the status of getting these two to behave well together?

Specifically, the ability to "autoproxy" (or any proxy with cglib) an action.

It works for a little while(transaction code works too), but after 10 minutes or so it breaks when the invocation of the action look throws a class cast exception.

Note Spring 1.1 did not fix the problem(prehaps it now takes longer for the problem to occur).

Is this a Spring issue or an Xwork issue? Is XWork caching the classes rather than retrieving them fresh from spring everytine?

-Matt

-->
java.lang.IllegalArgumentException: java.lang.ClassCastException@4815e
sun.reflect.GeneratedMethodAccessor181.invoke(Unkn own Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.opensymphony.xwork.DefaultActionInvocation.inv okeAction(DefaultActionInvocation.java:302)
com.opensymphony.xwork.DefaultActionInvocation.inv oke(DefaultActionInvocation.java:170)
com.opensymphony.xwork.interceptor.AroundIntercept or.intercept(AroundInterceptor.java:35)
com.opensymphony.xwork.DefaultActionInvocation.inv oke(DefaultActionInvocation.java:165)
com.opensymphony.xwork.interceptor.AroundIntercept or.intercept(AroundInterceptor.java:35)
com.opensymphony.xwork.DefaultActionInvocation.inv oke(DefaultActionInvocation.java:165)
com.opensymphony.xwork.interceptor.AroundIntercept or.intercept(AroundInterceptor.java:35)
com.opensymphony.xwork.DefaultActionInvocation.inv oke(DefaultActionInvocation.java:165)
com.opensymphony.xwork.interceptor.AroundIntercept or.intercept(AroundInterceptor.java:35)
com.opensymphony.xwork.DefaultActionInvocation.inv oke(DefaultActionInvocation.java:165)
com.opensymphony.xwork.DefaultActionProxy.execute( DefaultActionProxy.java:115)
com.opensymphony.webwork.dispatcher.ServletDispatc her.serviceAction(ServletDispatcher.java:278)
com.opensymphony.webwork.dispatcher.ServletDispatc her.service(ServletDispatcher.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
com.opensymphony.webwork.lifecycle.RequestLifecycl eFilter.doFilter(RequestLifecycleFilter.java:69)
com.opensymphony.module.sitemesh.filter.PageFilter .parsePage(PageFilter.java:142)
com.opensymphony.module.sitemesh.filter.PageFilter .doFilter(PageFilter.java:58)
org.springframework.orm.hibernate.support.OpenSess ionInViewFilter.doFilterInternal(OpenSessionInView Filter.java:161)
org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:73)

Colin Sampaleanu
Aug 25th, 2004, 02:53 PM
I'm not 100% clear on the exact sequenc of events here, but I can say that the Spring generated proxy is not magically mutating somehow.

Is the class being wrapped a prototype or singleton, first of all?

sutter2k
Aug 25th, 2004, 06:39 PM
The class is being wrapped as a "prototype".




There are more details on the issue here --->

http://jira.opensymphony.com/browse/XW-174

example of one of the actions


...
<bean id="dnsServerOptions" class="com.diamondip.ipcontrol.actions.DnsServerOptions" singleton="false" autowire="byType"/>
...
<bean id="actionAutoProxy" class="org.springframework.aop.framework.autoproxy.BeanNa meAutoProxyCreator">
<property name="interceptorNames">
<list>
<value>myTxInterceptor</value>
</list>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="beanNames"><value>dnsViewAction,dnsServerAction,dnsZoneAction</value></property>
</bean>
....