spring - NoSuchMethodException thrown by AnnotationValidationInterceptor when executing an action -


details of jars used: struts2 2.2.1 spring 3.0.5.release hibernate 3.6.0.final

i experiencing strange issue when trying execute action mapped follows:

<action name="suppliersearch" class="suppliersearchaction">             <result>/pages/suppliersearch.jsp</result> </action> <action name="searchforsupplier" class="suppliersearchaction" method="dosearch"> <result>/pages/suppliersearch.jsp</result> </action> 

the first action sends user search page, enter search string , second action invoked when post form.

the action in spring config follows:

<bean id="suppliersearchaction"     class="com.blah.suppliersearchaction"     scope="prototype">     <property name="searchservice" ref="suppliersearchservice"></property> </bean> 

the search service uses hibernate search , defined follows:

<bean id="suppliersearchservice"         class="com.devcentre.yubi.application.service.suppliersearchserviceimpl">         <property name="sessionfactory" ref="sessionfactory"></property>     </bean> 

i using spring aop configure transaction boundaries , persistence config follows:

<tx:annotation-driven transaction-manager="txmanager" />      <bean id="sessionfactory"         class="org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean">         <property name="datasource" ref="datasource" />         <property name="annotatedclasses">             <list>                 // annotated classes here             </list>         </property>         <property name="hibernateproperties">             <props>                 <prop key="hibernate.dialect"> org.hibernate.dialect.mysqldialect</prop>                 <prop key="hibernate.show_sql">true</prop>                 <prop key="hibernate.hbm2ddl.auto">upgrade</prop>                 <prop key="hibernate.cache.use_second_level_cache">true</prop>                 <prop key="hibernate.cache.provider_class">                     net.sf.ehcache.hibernate.singletonehcacheprovider</prop>                 <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.fsdirectoryprovider                 </prop>                 <prop key="hibernate.search.default.indexbase">/lucene/indexes</prop>                 <prop key="hibernate.search.default.batch.merge_factor">10</prop>                 <prop key="hibernate.search.default.batch.max_buffered_docs">10</prop>             </props>         </property>      </bean>      <bean id="txmanager"         class="org.springframework.orm.hibernate3.hibernatetransactionmanager">         <property name="sessionfactory" ref="sessionfactory" />     </bean> 

spring configured follows in web.xml:

<listener>         <listener-class>             org.springframework.web.context.contextloaderlistener         </listener-class>     </listener>      <listener>         <listener-class>org.springframework.web.context.request.requestcontextlistener</listener-class>     </listener>      <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>             /web-inf/src/spring-config.xml              /web-inf/src/persistence-config.xml          </param-value>     </context-param> 

on search jsp page have form submits search string action should invoke dosearch method. however, when submit search exception follows (because devmode enabled):

struts has detected unhandled exception:  messages:    $proxy28.dosearch() file:   java/lang/class.java line number: 1,605 

and stack trace:

java.lang.nosuchmethodexception: $proxy28.addcomponent()     java.lang.class.getmethod(class.java:1605)     org.apache.struts2.interceptor.validation.annotationvalidationinterceptor.getactionmethod(annotationvalidationinterceptor.java:75)     org.apache.struts2.interceptor.validation.annotationvalidationinterceptor.dointercept(annotationvalidationinterceptor.java:47)     com.opensymphony.xwork2.interceptor.methodfilterinterceptor.intercept(methodfilterinterceptor.java:98) 

this odd because there method on action class signature:

public string dosearch() 

can shed light on why actionproxy doesn't have expected method?

thanks,

alex

java.lang.nosuchmethodexception: $proxy25.dosearch()

notice name of action class $proxy25. appears creating dynamic proxy action class. seen when using aspect oriented programming (aop) method interceptors on methods of class — e.g., things transactions.

for example, use google guice time-to-time , when using aop method interceptors on methods of class, action called loginaction have dynamic proxy created called loginaction$$enhancerbyguice$$someadditionalcharacters. while dynamic proxy subclasses methods of class, not inherit annotations. guess same thing happening here.

i don't use spring, not familiar libraries uses create dynamic proxies.

update

if remove aop annotations action class, should work expected. action class can delegate service-layer class handle persisting database (you can put @transactional annotation on class's method(s)).


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -