[英]unable to locate Spring NamespaceHandler error
我已經有這個錯誤已經有將近一個星期了,我現在就准備好了。我已經使用Maven2制作了BIG jar文件。 當我使用以下命令運行jar文件時:
java -jar someJar.jar
我收到此錯誤:
ERROR: [27/55/13 10:55] Launcher: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [JavaProjectApplicationContext.xml]
JavaProjectApplicationContext.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>deployment.properties</value></property>
</bean>
<bean id="LexEditorDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"><value>${hibernate.jdbc_driver}</value></property>
<property name="username"><value>${hibernate.username}</value></property>
<property name="password"><value>${hibernate.password}</value></property>
<property name="url"><value>${hibernate.url}</value></property>
<property name="defaultAutoCommit"><value>${hibernate.default_auto_commit}</value> </property>
<property name="maxActive"><value>20</value></property>
<property name="maxIdle"><value>3</value></property>
<property name="testOnBorrow"><value>true</value></property>
<property name="testOnReturn"><value>true</value></property>
<property name="testWhileIdle"><value>true</value></property>
</bean>
<context:component-scan base-package="com.k_int.bank.plugin">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
<bean id="ThesSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource"><ref local="LexEditorDataSource"/></property>
<property name="configurationClass"> <value>org.hibernate.cfg.AnnotationConfiguration</value></property>
<property name="packagesToScan">
<list>
<value>com.bank.kernel.datamodel</value>
</list>
</property>
<property name="annotatedClasses">
<list>
<!-- identity service -->
<value>com.svc.identity.datamodel.PartyHDO</value>
<value>com.svc.identity.datamodel.RegisteredUserHDO</value>
<value>com.svc.identity.datamodel.AuthenticationDetailsHDO</value>
<value>com.svc.identity.datamodel.GrantHDO</value>
<value>com.svc.identity.datamodel.PermissionHDO</value>
<value>com.svc.identity.datamodel.RegisteredOrganisationHDO</value>
<value>com.svc.identity.datamodel.RoleHDO</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<bean id="IndexService" class="com.k_int.bank.index.solr_impl.SOLRIndexService" init-method="init">
<property name="indexDirectory"><value>${com.bank.index_dir}</value></property>
<property name="indexPropertyFile"><value>solr.properties</value></property>
</bean>
到目前為止我嘗試過的事情。
以3種不同的方式構建項目(2個IDE和命令行)刪除任何jar依賴性沖突(我有spring-2.5.6.jar和spring-context-3.0.5.RELEASE.jar,所以我刪除了spring-2.5.6 。罐)
將http://www.springframework.org/schema/beans/spring-beans-2.5.xsd更改為http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 。
這些更改都沒有刪除錯誤。
在汽車文件中存在
someJar.jar/org/springframework/context/config/ContextNameSpaceHandler.class
有沒有人有任何想法。
很可能發生的事情是,向Spring提供有關自定義命名空間處理程序(spring.schema,spring.handlers)位置的元數據的文件在創建大(超級)jar時最終會覆蓋彼此。
為了澄清這一點,如果您使用上下文名稱空間 - context:property-placeholder-configurer
,有關如何解析此命名空間的信息是在spring-context.jar!:/META-INF/spring.handlers
使用spring.handlers文件spring-context.jar!:/META-INF/spring.handlers
文件,其他spring jar文件中存在類似的文件,用於其他自定義命名空間支持。 現在,當您創建Uber jar時,由於處理程序文件的位置完全相同,因此一個spring.handler文件將最終覆蓋其他文件,並且您會看到您看到的錯誤。 這里描述了一些可能的修復,其中建議了一些創建可執行jar的替代方法:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.