2012-01-09 12 views
7

Qualche idea, che cosa potrebbe causare questo errore?Impossibile trovare Spring NamespaceHandler per lo spazio dei nomi dello schema XML [http://www.springframework.org/schema/data/jpa]

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: problema di configurazione: Impossibile individuare primavera NamespaceHandler per schema XML namespace [http://www.springframework.org/schema/data/jpa] risorsa Offending: risorsa ServletContext [/WEB-INF/spring/appServlet/servlet-context.xml]

ecco il mio 'servle-context.xml' (ci sono alcuni problemi con i rientri, ma il file è troppo grande ...):

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:beans="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:jpa="http://www.springframework.org/schema/data/jpa" 
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
        http://www.springframework.org/schema/data/jpa 
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> 

<!-- Enables the Spring MVC @Controller programming model --> 
<annotation-driven /> 

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> 
<resources mapping="/resources/**" location="/resources/" /> 

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> 
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <beans:property name="prefix" value="/WEB-INF/views/" /> 
    <beans:property name="suffix" value=".jsp" /> 
</beans:bean> 

<context:component-scan base-package="com.epam.mvc3.model" /> 
<context:component-scan base-package="com.epam.mvc3.controller" /> 

<!-- JPA --> 
<beans:bean 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <beans:property name="location"> 
     <beans:value>resources/database.properties</beans:value> 
    </beans:property> 
</beans:bean> 

<beans:bean id="myDataSource" 
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
    <beans:property name="driverClassName"> 
     <beans:value>${jdbc.driverClassName}</beans:value> 
    </beans:property> 
    <beans:property name="url"> 
     <beans:value>${jdbc.url}</beans:value> 
    </beans:property> 
    <beans:property name="username"> 
     <beans:value>${jdbc.username}</beans:value> 
    </beans:property> 
    <beans:property name="password"> 
     <beans:value>${jdbc.password}</beans:value> 
    </beans:property> 
</beans:bean> 

<beans:bean id="myEmf" 
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    <beans:property name="dataSource" ref="myDataSource" /> 

    <beans:property name="persistenceUnitName" value="application" /> 
    <beans:property name="persistenceXmlLocation" 
     value="classpath*:META-INF/persistence.xml" /> 
    <beans:property name="jpaVendorAdapter" ref="hibernateVendor" /> 

    <beans:property name="loadTimeWeaver"> 
     <beans:bean 
      class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"></beans:bean> 
    </beans:property> 
</beans:bean> 

<beans:bean id="hibernateVendor" 
    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
</beans:bean> 

<beans:bean id="transactionManager" 
    class="org.springframework.orm.jpa.JpaTransactionManager"> 
    <beans:property name="entityManagerFactory" ref="myEmf"></beans:property> 
</beans:bean> 

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

<!-- Spring Data configuration --> 
<jpa:repositories base-package="com.epam.mvc3.repository"/> 

</beans:beans> 

Come puoi vedere, ho specificato il percorso dello schema jpa. E io non so qual è il problema

+0

si prega di inviare l'intestazione completa del vostro XML. – Kai

+0

è fatto ...... – Eugene

+0

Assicurarsi di disporre di Spring Data Jar nel classpath. – axtavt

risposta

3

provare a sostituire

http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

da

http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd

Ma se si utilizza ancora la versione 1.0-M1 quindi provare a primo aggiornamento . DATAJPA-21

+0

Sebbene questa sia la risposta accettabile, non ha risolto questo problema per me. Io uso spring-data-jpa 1.2.0.RELEASE e il resto dei miei vasi a molla sono 3.1.3.RELEASE.Riguardo a spring-data-commons-core - Non ho nemmeno una dipendenza nel mio pom ma posso vederlo nel mio repository m2 insieme a spring-data-commons-parent ed entrambi della versione 1.4.0.RELEASE, I don Non so perché (forse quelli fanno parte di spring-data-jpa?). Qualche nuova intuizione? – forhas

+0

@forhas: questa è una domanda diversa. Quindi crea una nuova domanda Stack Overflow (Descrivi il tuo Probelem, configurazione ed eccezione, così come quello che hai provato in questo modo) e forse lascia un link alla tua domanda qui come commento. – Ralph

+0

Grazie Ralph, lo farò. – forhas

0

Il problema è dovuto al fatto che lo schema spring-jpa non può essere localizzato. Potresti avere un vecchio jar che non contiene le informazioni sullo schema.

+0

Sto utilizzando "hibernate-core-3.6.3.Final.jar", "hibernate-jpa-2.0-api-1.0.0.Final.jar", "spring-data-commons-core-1.1.0 .RELEASE.jar "," spring-orm-3.0.5.RELEASE.jar ". Pensi che siano obsoleti? – Eugene

+0

@Eugene stai usando lo spazio dei nomi spring-jpa - Non hai il vaso jpa di primavera? Potresti trovarlo [qui] (http://mirrors.ibiblio.org/pub/mirrors/maven2/org/springframework/spring-jpa/). –

1

Ho risolto questo risolvendo la mancanza della dipendenza tx molla nel nostro progetto.

org.springframework: primavera-tx

0

So che questo sembra stupido, ma se si utilizza IDEA e Maven si dovrebbe controllare per essere sicuri di avere Usa registro plugin di controllare in modo che il server ha anche accesso al vostro file jar.

Vorrei pubblicare una schermata ma sono nuovo qui e non ho abbastanza punti reputazione. Esso funziona e anche se ho verificato con il team di supporto a IntelliJ

2

Assicurarsi di avere la primavera-dati-APP nelle dipendenze

Se si utilizza Maven:

<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-jpa</artifactId> 
    <version>1.7.0.RELEASE</version> 
</dependency> 
0

Dopo aver affrontato questo lo stesso problema in una settimana, ho trovato una soluzione. Se si utilizza Spring MVC + APP + Maven, utilizzare questo dispatcher-servlet.xml

<?xml version="1.0" encoding="windows-1252"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/aop 
     http://www.springframework.org/schema/aop/spring-aop.xsd 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx.xsd"> 

    <!-- Use @Component annotations for bean definitions --> 
    <context:component-scan base-package="PACKAGE WHERE YOU CAN FIND YOUR SOURCE CODE"/> 

    <!-- Use @Controller annotations for MVC controller definitions --> 
    <mvc:annotation-driven /> 

    <!-- Add JPA support --> 
    <bean id="emf" class= 
      "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="loadTimeWeaver"> 
      <bean class= 
          "org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> 
     </property> 
    </bean> 

    <!-- Add Transaction support --> 
    <bean id="transactionManager" 
      class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="emf"/> 
    </bean> 

    <!-- Use @Transaction annotations for managing transactions --> 
    <tx:annotation-driven transaction-manager="transactionManager" /> 

    <!-- View resolver --> 
    <bean class= 

<!-- HERE YOU REPLACE PROPERTY VALUE TO MATCH YOUR VIEW FOLDER (JSP PAGES) --> 
        "org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/web/"/> 
     <property name="suffix" value=".jsp"/> 
    </bean> 

</beans> 
0

troppo tardi, ma questo risolto il mio problema:

<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-jpa</artifactId> 
    <version>1.9.4.RELEASE</version> 
</dependency> 
Problemi correlati