Announcement Announcement Module
Collapse
No announcement yet.
Transactional services => BeanNotOfRequiredTypeException, should be Advice, but is Tr Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactional services => BeanNotOfRequiredTypeException, should be Advice, but is Tr

    I can't find the solution to this problem...

    this is my application-servlet:
    Code:
    <!-- Utility Beans -->
        <!-- Mapptura tramite annotazioni -->
        <context:annotation-config />
    
        <context:component-scan base-package="it.home.ristech.Curriculum.dao"/>
    
        <tx:annotation-driven transaction-manager="transactionManager"/>
    
        <aop:config>
           <aop:pointcut expression="execution(* it.home.ristech.Curriculum.dao.*Dao.*(..))" id="dbMethods" />
           <aop:advisor advice-ref="txAdvice" pointcut-ref="dbMethods" />
        </aop:config>
    
        <tx:advice id="txAdvice" transaction-manager="transactionManager" >
            <tx:attributes>
                <tx:method name="*" propagation="REQUIRES_NEW" />
            </tx:attributes>
        </tx:advice>
    
        <mvc:annotation-driven />
    
        <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
    
        <bean id="user" class="it.home.ristech.Curriculum.model.Users" scope="session"></bean>
    
        <!-- Resource Bundle -->
    
        <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basename"><value>messages</value></property>
        </bean>
    
        <!-- Fine Resource Bundle -->
        
        <!-- Interceptor -->
    
        <bean name="openSessionInViewInterceptor"
              class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
            <property name="sessionFactory">
                <ref bean="SessionFactory" />
            </property>
        </bean>
    
        <!-- Fine Interceptor -->
    
            <!-- View Resolver -->
        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver"
            p:prefix="/WEB-INF/view/" p:suffix=".jsp" />
    
        <!-- Fine View Resolver -->
    
        <bean id="dataSource"
              class="org.springframework.jdbc.datasource.DriverManagerDataSource"
              p:driverClassName="com.mysql.jdbc.Driver" p:url="jdbc:mysql://database/curriculum"
              p:username="curriculum" p:password="curriculum" />
        <bean id="SessionFactory"
              class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
              p:dataSource-ref="dataSource">
            <property name="annotatedClasses">
                <list>
                    <value>it.home.ristech.Curriculum.model.CampoExtra</value>
                    <value>it.home.ristech.Curriculum.model.Curriculum</value>
                    <value>it.home.ristech.Curriculum.model.EsperienzaLavorativa</value>
                    <value>it.home.ristech.Curriculum.model.Lavoratore</value>
                    <value>it.home.ristech.Curriculum.model.PercorsoDiStudio</value>
                    <value>it.home.ristech.Curriculum.model.TipoCurriculum</value>
                    <value>it.home.ristech.Curriculum.model.TipoDiStudio</value>
                    <value>it.home.ristech.Curriculum.model.ValoreCampoExtra</value>
                    <value>it.home.ristech.Curriculum.model.LavoratoreAzienda</value>
                    <value>it.home.ristech.Curriculum.model.Azienda</value>
                    <value>it.home.ristech.Curriculum.model.Ruolo</value>
                    <value>it.home.ristech.Curriculum.model.Users</value>
                    <value>it.home.ristech.Curriculum.model.ListaValori</value>
                </list>
            </property>
            <!-- PROPRIETA' DI CONFIGURAZIONE HIBERANTE -->
            <property name="hibernateProperties">
                <props>
                    <prop key=" hibernate.connection.autocommit">true</prop>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
                    <prop key="hibernate.current_session_context_class">thread</prop>
    
                </props>
            </property>
        </bean>
        <bean id="transactionManager"
              class="org.springframework.orm.hibernate3.HibernateTransactionManager"
              p:sessionFactory-ref="SessionFactory" p:dataSource-ref="dataSource" />
    
        <!-- INIZIO DAO -->
    
        
        <bean  id="userBean" class="it.home.ristech.Curriculum.dao.UsersDao"  >
            <property name="SessionFactory">
                <ref local="SessionFactory"/>
            </property>
        </bean>
    
        <!-- FINE DAO -->
    
        <!-- MAPPATURA JSP -->
    
        <bean id="urlMap"
              class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="interceptors">
                <list>
                    <ref bean="openSessionInViewInterceptor" />
                </list>
            </property>
            <property name="urlMap">
                <props>
                    <prop key="/Login.htm">loginController</prop>              
                    <prop key="/SceltaHome.htm">controller</prop>
                </props>
            </property>
        </bean>
    
        <!-- FINE MAPPATURA JSP -->
    
            <!-- VALIDATOR -->
    
        <bean name="userValidator" class="it.home.ristech.Curriculum.validators.UserValidator">
        </bean>
    
        <!-- FINE VALIDATOR -->
    
        <!-- DICHIARAZIONE BEANS CONTROLLER -->
    
        <bean name="controller" class="it.home.ristech.Curriculum.controller.CustomController">
        </bean>
        <bean name="loginController" class="it.home.ristech.Curriculum.controller.LoginController">
            <property name="userDao" ref="userBean"></property>
            <property name="validator" ref="userValidator"/>
        </bean>
    
        <!-- FINE BEANS CONTROLLER -->
    
    </beans>
    this is the exception:

    Code:
    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    javax.servlet.ServletException: Servlet.init() for servlet Curriculum threw exception
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    	java.lang.Thread.run(Thread.java:619)
    root cause
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBean' defined in ServletContext resource [/WEB-INF/Curriculum-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' must be of type [org.aopalliance.aop.Advice], but was actually of type [org.springframework.transaction.interceptor.TransactionInterceptor]
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    	java.lang.Thread.run(Thread.java:619)
    thanks all for the help
    Last edited by l.pieralisi; Jul 5th, 2010, 06:16 AM.

  • #2
    1) Why are you using/mixing 2 transcation strategies (annotations and xml)
    2) Remove the current_session_context it will break proper tx management
    3) Your session scoped bean should include a <aop:scoped-proxy /> else it won't work
    4) You use component scanning but still define the beans
    5) Remove context:annotation-config that is implied by component-scanning.
    6) Remove the AnnotationMethodHandlerAdapter, already registered
    7) Why do you have an interceptor only for the SimpleUrlHandlerMapping and not for annotations?
    8) Your hibernate.connection properties are useless on the sessionfactory bean

    Although nog all of them are related to your problem, I would start by cleaning up to make it clearer and more consise.
    Last edited by Marten Deinum; Jul 5th, 2010, 06:59 AM.

    Comment


    • #3
      First of all, sorry for my poor English
      I may have solved some problems I've listed but I can not understand some of them
      could you kindly post your own solution?

      now this is my file (I'll post it without main <beans> tag):
      Code:
          <context:component-scan base-package="it.home.ristech.Curriculum.dao"/>
      
          <tx:annotation-driven transaction-manager="transactionManager"/>
          <aop:config >
             <aop:pointcut expression="execution(* it.home.ristech.Curriculum.dao.*Dao.*(..))" id="dbMethods" />
             <aop:advisor advice-ref="txAdvice" pointcut-ref="dbMethods" />
          </aop:config>
      
          <tx:advice id="txAdvice" transaction-manager="transactionManager" >
              <tx:attributes>
                  <tx:method name="*" propagation="REQUIRES_NEW" />
              </tx:attributes>
          </tx:advice>
      
          <mvc:annotation-driven />
      
          <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
      
          <bean id="user" class="it.home.ristech.Curriculum.model.Users" scope="session"></bean>
      
          <!-- Resource Bundle -->
      
          <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
              <property name="basename"><value>messages</value></property>
          </bean>
      
          <!-- Fine Resource Bundle -->
          
          <!-- Interceptor -->
      
          <bean name="openSessionInViewInterceptor"
                class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
              <property name="sessionFactory">
                  <ref bean="SessionFactory" />
              </property>
          </bean>
      
          <!-- Fine Interceptor -->
      
              <!-- View Resolver -->
          <bean
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix="/WEB-INF/view/" p:suffix=".jsp" />
      
          <!-- Fine View Resolver -->
      
          <bean id="dataSource"
                class="org.springframework.jdbc.datasource.DriverManagerDataSource"
                p:driverClassName="com.mysql.jdbc.Driver" p:url="jdbc:mysql://database/curriculum"
                p:username="curriculum" p:password="curriculum" />
          <bean id="SessionFactory"
                class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
                p:dataSource-ref="dataSource">
              <property name="annotatedClasses">
                  <list>
                      <value>it.home.ristech.Curriculum.model.CampoExtra</value>
                      <value>it.home.ristech.Curriculum.model.Curriculum</value>
                      <value>it.home.ristech.Curriculum.model.EsperienzaLavorativa</value>
                      <value>it.home.ristech.Curriculum.model.Lavoratore</value>
                      <value>it.home.ristech.Curriculum.model.PercorsoDiStudio</value>
                      <value>it.home.ristech.Curriculum.model.TipoCurriculum</value>
                      <value>it.home.ristech.Curriculum.model.TipoDiStudio</value>
                      <value>it.home.ristech.Curriculum.model.ValoreCampoExtra</value>
                      <value>it.home.ristech.Curriculum.model.LavoratoreAzienda</value>
                      <value>it.home.ristech.Curriculum.model.Azienda</value>
                      <value>it.home.ristech.Curriculum.model.Ruolo</value>
                      <value>it.home.ristech.Curriculum.model.Users</value>
                      <value>it.home.ristech.Curriculum.model.ListaValori</value>
                  </list>
              </property>
              <!-- PROPRIETA' DI CONFIGURAZIONE HIBERANTE -->
              <property name="hibernateProperties">
                  <props>
                      <prop key=" hibernate.connection.autocommit">true</prop>
                      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
                      <prop key="hibernate.show_sql">true</prop>
                      <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
                  </props>
              </property>
          </bean>
          <bean id="transactionManager"
                class="org.springframework.orm.hibernate3.HibernateTransactionManager"
                p:sessionFactory-ref="SessionFactory" p:dataSource-ref="dataSource" />
      
          <!-- INIZIO DAO -->
          <bean  id="esperienzaLavorativaBean" class="it.home.ristech.Curriculum.dao.EsperienzaLavorativaDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="percorsoDiStudioBean" class="it.home.ristech.Curriculum.dao.PercorsoDiStudioDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="tipoCurriculumBean" class="it.home.ristech.Curriculum.dao.TipoCurriculumDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="tipoDiStudioBean" class="it.home.ristech.Curriculum.dao.TipoDiStudioDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="valoreCampoExtraBean" class="it.home.ristech.Curriculum.dao.ValoreCampoExtraDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="aziendaBean" class="it.home.ristech.Curriculum.dao.AziendaDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="userBean" class="it.home.ristech.Curriculum.dao.UsersDao"  >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="lavoratoreBean" class="it.home.ristech.Curriculum.dao.LavoratoreDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="campoExtraBean" class="it.home.ristech.Curriculum.dao.CampoExtraDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <bean  id="curriculumBean" class="it.home.ristech.Curriculum.dao.CurriculumDao" >
              <property name="SessionFactory">
                  <ref local="SessionFactory"/>
              </property>
          </bean>
          <!-- FINE DAO -->
      
          <!-- MAPPATURA JSP -->
          <bean id="urlMap"         class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
              <property name="interceptors">
                  <list>
                      <ref bean="openSessionInViewInterceptor" />
                  </list>
              </property>
              <property name="urlMap">
                  <props>
                      <prop key="/Login.htm">loginController</prop>
                      <prop key="/RegistratiCome.htm">controller</prop>
                      <prop key="/SceltaHome.htm">controller</prop>
                      <prop key="/HomeAzienda.htm">controller</prop>
                      <prop key="/HomeAmministrazione.htm">controller</prop>
                      <prop key="/VisualizzaProfilo.htm">profiloAziendaController</prop>
                      <prop key="/VisualizzaCurriculum.htm">curriculumController</prop>
                      <prop key="/VisualizzaContatti.htm">contattiController</prop>
                      <prop key="/VisualizzaCurriculumAziende.htm">curriculumAziendeController</prop>
                      <prop key="/VisualizzaCurriculumSingolo.htm">curriculumSingoloController</prop>
                      <prop key="/userIndexAzienda.htm">userIndexAziendaController</prop>
                      <prop key="/userIndex.htm">userIndexLavoratoreController</prop>
                      <prop key="/InserisciCurriculum.htm">nuovoCurriculumController</prop>
                      <prop key="/RegistraAzienda.htm">registraAziendaController</prop>
                      <prop key="/RegistraLavoratore.htm">registraLavoratoreController</prop>
                      <prop key="/RegistraLavoratore.htm">registraLavoratoreController</prop>
                      <prop key="/InserisciPercorso.htm">inserisciPercorsoController</prop>
                      <prop key="/InserisciEsperienza.htm">inserisciEsperienzaController</prop>
                  </props>
              </property>
          </bean>
          <!-- FINE MAPPATURA JSP -->
      
              <!-- VALIDATOR -->
          <bean name="userValidator" class="it.home.ristech.Curriculum.validators.UserValidator">
          </bean>
      
          <!-- FINE VALIDATOR -->
      
          <!-- DICHIARAZIONE BEANS CONTROLLER -->
      
          <bean name="controller" class="it.home.ristech.Curriculum.controller.CustomController">
          </bean>
          <bean name="loginController" class="it.home.ristech.Curriculum.controller.LoginController">
              <property name="userDao" ref="userBean"></property>
              <property name="validator" ref="userValidator"/>
          </bean>
          <bean name="registraAziendaController" class="it.home.ristech.Curriculum.controller.RegistraAziendaController">
              <property name="aziendaDao" ref="aziendaBean"></property>
              <property name="userDao" ref="userBean"></property>
          </bean>
          <bean name="registraLavoratoreController" class="it.home.ristech.Curriculum.controller.RegistraLavoratoreController">
              <property name="lavoratoreDao" ref="lavoratoreBean"></property>
          </bean>
          <bean name="profiloAziendaController" class="it.home.ristech.Curriculum.controller.ProfiloAziendaController">
              <property name="aziendaDao" ref="aziendaBean"></property>
          </bean>
          <bean name="curriculumController" class="it.home.ristech.Curriculum.controller.CurriculumController">
              <property name="lavoratoreDao" ref="lavoratoreBean"></property>
              <property name="aziendaDao" ref="aziendaBean"></property>
          </bean>
      .
      .
      .
      [Other controller declarations]
      </beans>
      thanks in advance for your patience and your help

      Comment


      • #4
        For starters I suggest reading my post with all the suggestions, strip down/fix your configuration there is to much conflicting stuff in there. Fix that first.

        Comment

        Working...
        X