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

  • Exception in XML

    Hi,
    I'm trying to run a method that insert an Object in a database, but this exception occur:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [spring-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mySessionFactory' of bean class [org.springframework.orm.hibernate3.HibernateTransactionManager]: Bean property 'mySessionFactory' 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.NotWritablePropertyException: Invalid property 'mySessionFactory' of bean class [org.springframework.orm.hibernate3.HibernateTransactionManager]: Bean property 'mySessionFactory' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    And this is my XML:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    <beans>
       
       <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
          <property name="configLocation">
              <value>hibernate.cfg.xml</value>
          </property>
          
       </bean>
       
       
       <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
          <property name="mySessionFactory">
             <ref local="mySessionFactory"/>
          </property>
       </bean>
       <bean id="UsuarioDao" class="br.gov.pa.tj.usuario.dao.UsuarioDAOImpl">
          <property name="mySessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="ComarcaDao" class="br.gov.pa.tj.comarca.dao.ComarcaDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="DiretorioDao" class="br.gov.pa.tj.diretorio.dao.DiretorioDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="EventoDao" class="br.gov.pa.tj.evento.dao.EventoDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="EventoNaoPermitidoDao" class="br.gov.pa.tj.eventoNaoPermitido.dao.EventoNaoPermitidoDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="EventoProgramaDao" class="br.gov.pa.tj.eventoPrograma.dao.EventoProgramaDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="GrupoDao" class="br.gov.pa.tj.grupo.dao.GrupoDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="ModuloDao" class="br.gov.pa.tj.modulo.dao.ModuloDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="ProgramaDao" class="br.gov.pa.tj.programa.dao.ProgramaDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="ProgramaGrupoDao" class="br.gov.pa.tj.programaGrupo.dao.ProgramaGrupoDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="RegistroAcessoDao" class="br.gov.pa.tj.registroAcesso.dao.RegistroAcessoDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       
       <bean id="SistemaDao" class="br.gov.pa.tj.sistema.dao.SistemaDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       
       
       <bean id="SistemaFacade"
            class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
                       <property name="transactionManager"><ref local="transactionManager"/></property>
                       <property name="target"><ref local="SistemaFacadeTarget"/></property>
                       <property name="transactionAttribute">
                          <props>
                             <prop key="inserir*">PROPAGATION_REQUIRED</prop>
                             <prop key="alterar*">PROPAGATION_REQUIRED</prop>
                             <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
                          
                          
                          </props>
                       
                       
                       </property>
                       
       
       </bean>
       
       <bean id="SistemaFacadeTarget"
          class="br.gov.pa.tj.sistema.facade.SistemaFacadeImpl">
          <property name="SistemaDAO"><ref local="SistemaDao"/></property>
       
       </bean>
       
       <bean id="UsuarioComarcaDao" class="br.gov.pa.tj.usuarioComarca.dao.UsuarioComarcaDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
       <bean id="UsuarioGrupoDao" class="br.gov.pa.tj.usuarioGrupo.dao.UsuarioGrupoDAOImpl">
          <property name="sessionFactory">
             <ref bean="mySessionFactory"/>
          </property>
       </bean>
    </beans>
    Someone know how and where?
    Regards

  • #2
    You have an error in this code:

    Code:
    <bean id="UsuarioDao" class="br.gov.pa.tj.usuario.dao.UsuarioDAOImpl"> 
          <property name="mySessionFactory"> 
             <ref bean="mySessionFactory"/> 
          </property> 
       </bean>
    Notice that the property is incorrectly identified as mySessionFactory and should be simply session factory. Check out the reference manual for information on using parent/child beans to simply the configuration of your DAO objects.

    Rob

    Comment

    Working...
    X