Announcement Announcement Module
Collapse
No announcement yet.
Type Mismatch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Type Mismatch

    Do you see any mistake in this piece of code?

    This is my netbeans error message:
    Code:
    Error creating bean with name 'facadeAvvisi' defined in file [...\web\WEB-INF\applicationContext.xml]: Error setting property values;
     nested exception is org.springframework.beans.NotWritablePropertyException:
     Invalid property 'aDao' of bean class [...sistema.FacadeAvvisi]:
     Bean property 'aDao' is not writable or has an invalid setter method:
     Does the parameter type of the setter match the return type of the getter?
    this is a piece of the ApplicationContext.xml:

    Code:
    <bean id="facadeAvvisi" class="org.apache.shale.progettotesi.sistema.FacadeAvvisi">
            <property name="aDao">
                <ref bean="avvisoDao"></ref>
            </property>
    </bean>
    
    ...
    
    <bean id="avvisoDao" class="org.apache.shale.progettotesi.persistenza.impl.AvvisoDaoImpl">
            <property name="dataSource">
                <ref bean="dataSource"></ref>
            </property>
    </bean>
    and these are my java class(only a piece..):

    Code:
    public class FacadeAvvisi{
    
    private AvvisoDao aDao;
    //getter and setter
    }
    
    public interface AvvisoDao {
        ...
    }
    
    public class AvvisoDaoImpl extends JdbcDaoSupport implements AvvisoDao, RowCallbackHandler{
    ...
    }
    It seems that there is a type mismatch between the property in the AppContext.xml and the java variable.But actually it isn't..

    thanks 4 help

  • #2
    can u post the setter?

    Comment


    • #3
      You left out the interesting part

      Can you post the getter and setter of the Dao?

      Regards,
      Andreas

      Comment


      • #4
        this are getter/setter of facadeAvvisi:

        Code:
        public class FacadeAvvisi {
            
            private AvvisoDao aDao;
        ..
        public AvvisoDao getADao() {
                return aDao;
            }
        
            public void setADao(AvvisoDao aDao) {
                this.aDao = aDao;
            }
        ..
        }

        Comment


        • #5
          That's a special case of the JavaBeans specification. Normally, if you have a property named "dao", the according setter will be "setDao" (note the case).
          If, however, a property name starts with two uppercase letters, then it stands as is. So for your case, the correct property name (matching your getter/setter) is "ADao". Take this as name in your app context file, and things should work.

          Regards,
          Andreas

          Comment


          • #6


            thanks 4 help

            Comment


            • #7
              or:
              Code:
              public class FacadeAvvisi {
                  
                  private AvvisoDao avvisoDao;
              ..
              public AvvisoDao getAvvisoDao() {
                      return avvisoDao;
                  }
              
                  public void setAvvisoDao(AvvisoDao aDao) {
                      this.avvisoDao = aDao;
                  }
              ..
              }
              and
              Code:
              <bean id="facadeAvvisi" class="org.apache.shale.progettotesi.sistema.FacadeAvvisi">
                      <property name="avvisoDao">
                          <ref bean="avvisoDao"></ref>
                      </property>
              </bean>

              Comment

              Working...
              X