Announcement Announcement Module
Collapse
No announcement yet.
Injecting property into a abstract class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting property into a abstract class

    I have the following two classes. The one is abstract base class and the other extends the abstract class.

    public abstract class AbstractSimpleFormController extends SimpleFormController{

    private String selfRedirectErrorView;

    public final void SetSelfRedirectErrorView(String selfRedirectErrorView){
    this.selfRedirectErrorView = selfRedirectErrorView;
    }

    ...
    }

    public class SignUpFormController extends AbstractSimpleFormController {
    ...
    }

    My Application context is configured as follows:

    <bean id="signupFormController" class="com.web.SignUpFormController">
    ...
    <property name="selfRedirectErrorView"><value>redirect:/signup.htm</value></property>
    </bean>

    Now when I try to start the application, I get the following error. Can someone help me? I thought I can inject into the property of a base class. What is going wrong? I also tried by making the base class non-abstract but got the same effect. I also changed the private property of the base class to protected with the same effect. I'm using the Spring version of 1.2.6.

    2005-12-02 07:14:46,925 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'signupFormController' defined in ServletContext resource [/WEB-INF/myweb-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'selfRedirectErrorView' of bean class [com.web.SignUpFormController]: Bean property 'selfRedirectErrorView' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'selfRedirectErrorView' of bean class [com.web.SignUpFormController]: Bean property 'selfRedirectErrorView' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:567)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:469)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:626)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:653)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:642)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1023)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:824)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:345)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:275)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:134)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:246)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:184)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3692)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4127)
    at org.apache.catalina.manager.ManagerServlet.start(M anagerServlet.java:1175)
    at org.apache.catalina.manager.ManagerServlet.doGet(M anagerServlet.java:368)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:514)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:868)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:663)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

  • #2
    Code:
    public final void SetSelfRedirectErrorView(String selfRedirectErrorView)
    It needs to be setSelfRedirectErrorView (note the lower case 's'). All the methods that are being injected into need to conform to the JavaBean specification.

    This is also why its a very good idea to follow the Sun coding conventions - http://java.sun.com/docs/codeconv/

    Bob

    Comment


    • #3
      Oh, what a silly mistake! Thanks Cow Boy!

      Comment

      Working...
      X