Note that there are some explanatory texts on larger screens.

plurals
  1. PONo adapter for handler in Spring MVC
    text
    copied!<p>I have problem with simple spring mvc controller written in scala:</p> <pre><code>@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" } } </code></pre> <p>When I tried to access /hello.html I received exception:</p> <pre><code>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) </code></pre> <p>But when I removed @Transactional annotation - everything works!!. Spring can't find request mapping with two annotations? My applicationContext.xml fragment:</p> <pre><code> &lt;bean id="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"&gt; &lt;property name="sessionFactory" ref="sessionFactory"/&gt; &lt;/bean&gt; &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt; &lt;property name="interceptors"&gt; &lt;list&gt;&lt;ref bean="openSessionInViewInterceptor"/&gt;&lt;/list&gt; &lt;/property&gt; &lt;property name="alwaysUseFullPath" value="true" /&gt; &lt;/bean&gt; &lt;context:component-scan base-package="scala.hibernate"/&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt; &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt; &lt;property name="suffix" value=".jsp"/&gt; &lt;/bean&gt; &lt;!-- for transaction --&gt; &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManaager"&gt; &lt;property name="sessionFactory" ref="sessionFactory"/&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;/bean&gt; &lt;tx:annotation-driven/&gt; </code></pre> <p><strong>EDIT</strong></p> <p>Transactional aspect is applied using dynamic proxy, and it prevents Spring MVC from accessing the @RequestMapping annotations on the target class Solution:</p> <pre><code> &lt;tx:annotation-driven proxy-target-class="true"/&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload