Hi there,
converting Controllers of a spring mvc project from traditional style to new 2.5 annotation based controllers give me following proxy problems.
The interesting part of the class:
Note that the class implements no interface and has no default constructor.
PHP Code:@Controller
@RequestMapping("/login")
@SessionAttributes("login")
public class LoginController {
@Autowired
public LoginController(IUserService userService) {
_userService = userService;
}
...
The aop setup look as follow:
PHP Code:<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Controller</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>permissionAdvice</value>
</list>
</property>
</bean>
The controller class gets instantiated via DefaultAnnotationHandlerMapping.class.
Loading the context results in following exception:
If i use setter- instead of contructor-injection everythings work fine.PHP Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginController': Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.project.web.controller.LoginController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:413)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:332)
If i let the controller implement any interface (like Serializable) the context-loading happens without exception, but it comes to
Does anyone have a clue whats happening here ?PHP Code:javax.servlet.ServletException: No adapter for handler [com.project.web.controller.LoginController@ef77e9]: Does your handler implement a supported interface like Controller?
at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1086)
Johannes


Reply With Quote