nested exception is java.lang.IllegalStateException: Cannot create command without commandClass
I am getting following exception while using AbstractCommandController in spring framework.
The server encountered an internal error () that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Cannot create command without commandClass being set - either set commandClass or (in a form controller) override formBackingObject org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:488) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265) org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107) org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72) org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110) org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
Please help me in resolving this exception. Thanks in advance.
Related Post
Comments
One Response to “nested exception is java.lang.IllegalStateException: Cannot create command without commandClass”
Leave a Reply
It seems that you are not setting command class. If you are using AbstractCommandController then you need to set command class for that controller. An instance of this command class gets populated and validated on each request.
if you are not sure which command class to use or you don’t have any data in the request which needs to be populated then you can use Object as command bean.
public LoginController() {
setCommandClass(Object.class);
}