1

i 'm trying run a aplication in tomcat using spring + jsf + hibernate , but i heve the following error :

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-config.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

my spring-config.xml:

    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">

    <bean id="cadastraPacienteMB"
          class="br.com.prontuario.mb.CadastraPaciente" 
          scope="session"/>

    <bean id="pesquisaPacienteMB"
          class="br.com.prontuario.mb.PesquisaPaciente" 
          scope="session">
        <property name="editaPaciente" ref="editaPacienteMB"/>
    </bean>

    <bean id="editaPacienteMB"
          class="br.com.prontuario.mb.EditaPaciente"
          scope="session"/>

    <tx:annotation-driven transaction-manager="txManager"/>

    <context:annotation-config />

    <!-- Gerenciador de transacoes baseado em JPA -->
    <bean id="txManager"     class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
        <property name="dataSource" ref="myDataSource" />

    </bean>

    <!-- Fabrica de entity managers -->
    <bean id="entityManagerFactory" 
              class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="myDataSource" />
        <property name="jpaVendorAdapter">
            <bean     class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="true"/>
                <property name="generateDdl" value="true"/>
                <property name="database" value="PostgreSQL" />
            </bean>
        </property>
        <property name="jpaProperties">

            <props>
                <prop     key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            </props>
        </property>
    </bean>

    <!-- DataSource configurado para o banco de dados da aplicacao -->
    <bean id="myDataSource"
          class="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
        <property name="driverClassName" value="org.postgresql.Driver" />
            <property name="url"     value="jdbc:postgresql://localhost:5433/postgres"               />
            <property name="username" value="postgres" />
            <property name="password" value="postgres" />

        </bean>

    </beans>

1 Answer 1

2

You are using spring-tx (as you are using tx:annotation-driven). spring-tx depends on aopaliance and this jar is missing in your classpath:

java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor 

You can find it at:

http://mirrors.ibiblio.org/pub/mirrors/maven/aopalliance/jars/aopalliance-1.0.jar

Or (better) use maven...

3
  • the erros persist. i realize that my import xmlns:"" has no sugestion. its common? Jun 21, 2013 at 19:06
  • @Renanlf no . i' m using netbeans . Jun 21, 2013 at 22:05
  • How do you added it to the class path? The error shows that the class is not found so the aopalliance.jar seems not to be on the class path. Jun 24, 2013 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.