Getting java.lang.IllegalArgumentException: argument type mismatch error on using "RedirectAttributes" in spring MVC
<p>I am getting below error whenever I am using RedirectAttributes in my controller method if I am adding any other thing like ModelMap or Model then it is not giving any error. Why?</p>

<p>I checked on the net for the solution but I did not find anything.</p>

<blockquote>
  <p>java.lang.IllegalArgumentException: argument type mismatch
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p>
</blockquote>

<p>spring-servlet.xml</p>

<pre><code>             &lt;beans xmlns="http://www.springframework.org/schema/beans"  
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
                xmlns:p="http://www.springframework.org/schema/p"  
                xmlns:context="http://www.springframework.org/schema/context"
                xmlns:tx="http://www.springframework.org/schema/tx"
                xmlns:mvc="http://www.springframework.org/schema/mvc"
                xsi:schemaLocation="http://www.springframework.org/schema/beans  
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
                    http://www.springframework.org/schema/context  
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd
                    http://www.springframework.org/schema/mvc
                    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                    http://www.springframework.org/schema/tx
                    http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;  


                &lt;context:component-scan base-package="com.controller" /&gt;
                &lt;mvc:annotation-driven /&gt;
                &lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
                    &lt;property name="basename" value="classpath:messages" /&gt;
                    &lt;property name="defaultEncoding" value="UTF-8" /&gt;
                &lt;/bean&gt;

              &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
                  &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
                  &lt;property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /&gt;
                  &lt;property name="username" value="system" /&gt;
                  &lt;property name="password" value="system" /&gt;
             &lt;/bean&gt;
           &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
              &lt;property name="dataSource" ref="dataSource" /&gt;
              &lt;property name="configLocation"&gt;
                 &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
              &lt;/property&gt;
              &lt;property name="configurationClass"&gt;
                 &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
              &lt;/property&gt;
              &lt;property name="hibernateProperties"&gt;
                 &lt;props&gt;
                    &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.Oracle9Dialect&lt;/prop&gt;
                    &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                 &lt;/props&gt;
              &lt;/property&gt;
           &lt;/bean&gt;
           &lt;bean id="userDAO" class="userDAO.UserDAOImpl"/&gt;
            &lt;bean id="userService" class="userService.UserServiceImpl"/&gt;
                &lt;bean id="viewResolver"  
                    class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;  
                    &lt;property name="viewClass"&gt;  
                        &lt;value&gt;  
                            org.springframework.web.servlet.view.tiles2.TilesView  
                        &lt;/value&gt;  
                    &lt;/property&gt;  
                &lt;/bean&gt;  
                &lt;bean id="tilesConfigurer"  
                    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;  
                    &lt;property name="definitions"&gt;  
                        &lt;list&gt;  
                            &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt;  
                        &lt;/list&gt;  
                    &lt;/property&gt;  
                &lt;/bean&gt;


                &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
                &lt;bean id="transactionManager"
                    class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
                &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
            &lt;/bean&gt;

            &lt;/beans&gt; 

        //Controller class
               @RequestMapping("/Check")
            public String Check(@ModelAttribute("adduser") User user,ModelMap model,RedirectAttributes rd)
    //This is my function 
            {
                System.out.println(user.getUsername());
                System.out.println(user.getPassword());
                rd.addFlashAttribute("ajay", "Cjal");
                model.addAttribute("Username",user.getUsername());
                User result=userService.getByUserName(user.getUsername());
                System.out.println(result);
                if(result == null)
                {
                    userService.addUser(user);
                    return "redirect:SuccessfulRegistration.html";
                }
                else
                {
                    return "redirect:RegistrationError.html";
                }

            }
</code></pre>