No adapter for handler in Spring MVC

I have problem with simple spring mvc controller written in scala:

@Controller
class HelloWorldController {

 implicit def sessionFactory2Session(sf: SessionFactory) = sf.getCurrentSes
 @Autowired
  var sessionFactory: SessionFactory = null

 @Transactional 
 @RequestMapping(value=Array("/hello.html"),method = Array(RequestMethod.GET,RequestMethod.POST))
 def showHello  = {

   val document = new CustomDocument("name","custom")
   sessionFactory.save(document)
   sessionFactory.flush

   "helloPage"
  }
}

When I tried to access /hello.html I received exception:

javax.servlet.ServletException: No adapter for handler: Does your handler implement a supported interface like Controller?
at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:951)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:758)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)

But when I removed @Transactional annotation - everything works!!. Spring can't find request mapping with two annotations? My applicationContext.xml fragment:

 <bean id="openSessionInViewInterceptor"
       class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
     <property name="sessionFactory" ref="sessionFactory"/>
 </bean>

 <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
     <property name="interceptors">
         <list><ref bean="openSessionInViewInterceptor"/></list>
     </property>
     <property name="alwaysUseFullPath" value="true" />
 </bean>
<context:component-scan base-package="scala.hibernate"/>

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
              value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>
 </bean>

 <!-- for transaction -->
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManaager">
      <property name="sessionFactory" ref="sessionFactory"/>
      <property name="dataSource" ref="dataSource"/>
 </bean>
 <tx:annotation-driven/>

EDIT

Transactional aspect is applied using dynamic proxy, and it prevents Spring MVC from accessing the @RequestMapping annotations on the target class Solution:

    <tx:annotation-driven proxy-target-class="true"/>

Answers


Try adding <context:annotation-config /> to your applicationContext.xml and see if that fixes the problem.


declare following bean . this should solve the problem

<bean id="simpleHandler" class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

will update you once find out the root cause..


Need Your Help

Wordpress Help - Making a link populate on lower section of the page

php wordpress hyperlink wordpress-plugin

Wordpress Help - Making a link populate on lower section of the page

Symfony2 uncaught exception inside Event Listener

symfony exception listener uncaught-exception

I have a problem with throwing Symfony 2 exception inside event listner. When I do it I get Uncaught exception (onRequest method of listener). Is there any way to throw exception in listener that c...