Announcement Announcement Module
Collapse
No announcement yet.
Illegal Arguement Exception when defining a controller class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Illegal Arguement Exception when defining a controller class

    Hi All,

    When I try to define the controller in the application context xml file and deploy the ear file, I get the Illegal arguement exception. This is how I have defined the bean

    Code:
     <bean id="loginValidator" class="com.jbe.spring.web.validator.LoginValidator"/>
    
    	<bean id="loginController" class="com.jbe.spring.web.controller.LoginController">
    		<property name="sessionForm"><value>false</value></property>
    		<property name="commandName"><value>loginCommand</value></property>
    		<property name="commandClass"><value>com.jbe.spring.web.command.LoginCommand</value> </property>
    		<property name="validator"><ref bean="loginValidator"/></property>
    		<property name="formView"><value>/WEB-INF/jsp/login.jsp</value></property>
    	
    	</bean>
    Code:
    [5/18/06 3:26:56:219 PDT] 3e476052 ContextLoader E org.springframework.web.context.ContextLoader  TRAS0014I: The following exception was logged org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginController' defined in ServletContext resource [/WEB-INF/conf/context/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Validator [com.jbe.spring.web.validator.LoginValidator@486ca05d] does not support command class [com.jbe.spring.web.command.LoginCommand]
    java.lang.IllegalArgumentException: Validator [com.jbe.spring.web.validator.LoginValidator@486ca05d] does not support command class [com.jbe.spring.web.command.LoginCommand]
    	at org.springframework.web.servlet.mvc.BaseCommandController.initApplicationContext(BaseCommandController.java:240)
    	at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:79)
    	at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:84)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:216)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:333)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:310)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:133)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
    	at
    Please help me with this.

    Thanks,

    Karthik Krishnan

  • #2
    Well, all the information you need is there

    Code:
    java.lang.IllegalArgumentException: Validator [com.jbe.spring.web.validator.LoginValidator@486ca05d] does not support command class [com.jbe.spring.web.command.LoginCommand]
    What does LoginValidator.supports(final Class clazz) look like?

    Comment


    • #3
      LoginValidator supports method

      The supports method looks like this

      Code:
      LoginCommand.class.equals(clazz)
      where clazz is the Class param in the supports method
      Thanks for helping me out yatesco.

      Krishnan

      Comment


      • #4
        For robustness you probably want to do:
        Code:
        LoginCommand.class.isAssignableFrom(clazz);
        as this will cope with classes that extend LoginCommand as well.

        Can you please post the entire Validator code listing.

        Comment

        Working...
        X