2013-06-21 60 views
1

我試圖運行Tomcat的一個aplication的XML春+ JSF +冬眠,但我HEVE以下錯誤:錯誤的Spring配置

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)

我的春天-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> 

回答

2

您正在使用spring-tx(因爲您使用的是tx:annotation-driven)。彈簧TX取決於aopaliance這個罐子中缺少類路徑:

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

你可以找到它:

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

或(更好)用maven ...

+0

的堅持錯誤回報。我意識到我的導入xmlns:「」沒有消解。它的共同點? – user2509556

+0

問題未解決。我在classpaph中添加了罐子 – user2509556

+0

您使用的是maven嗎? – renanlf