无法找到Spring NamespaceHandler错误 [英] unable to locate Spring NamespaceHandler error

查看:71
本文介绍了无法找到Spring NamespaceHandler错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有将近一个星期的错误了,我正准备屈服. 我已经使用Maven2制作了BIG jar文件.当我使用以下命令运行jar文件时:

I have been having this error for nearly a week now and im just about ready to give in. I have used Maven2 to make the BIG jar file. When I run the jar file using:

 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如下:

JavaProjectApplicationContext.xml is as follows:

 <?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>





到目前为止我已经尝试过的事情.

Things I have tried so far.

以3种不同的方式(两个IDE和命令行)构建了项目 删除了所有jar依赖关系冲突(我有spring-2.5.6.jar和spring-context-3.0.5.RELEASE.jar,所以我删除了spring-2.5.6.jar)

built the project in 3 different ways (2 IDE's and command line) removed any jar dependancy clashes (I had spring-2.5.6.jar and spring-context-3.0.5.RELEASE.jar, So i removed spring-2.5.6.jar)

已更改 http://www.springframework.org/schema/beans/spring-beans- 2.5.xsd http://www.springframework.org/schema/beans/spring-beans-3.0.xsd .

这些更改都没有消除错误.

None of these changes have removed the error.

汽车文件中的

 someJar.jar/org/springframework/context/config/ContextNameSpaceHandler.class

有没有人有任何想法.

推荐答案

很有可能发生了一些文件,这些文件向Spring提供了有关自定义名称空间处理程序(spring.schema,spring.handlers)的位置的元数据.创建大(超大)jar时会互相覆盖.

Very likely what has happened is the files which provides meta data to Spring about the location of the custom namespace handlers(spring.schema, spring.handlers) have ended up overwriting each other when you created the big(uber) jar.

为了进一步说明这一点,如果您使用上下文名称空间说-context:property-placeholder-configurer,则有关如何解析此名称空间的信息是使用spring-context.jar!:/META-INF/spring.handlers文件中的spring.handlers文件,其中存在类似的文件.其他自定义名称空间支持的其他spring jar文件.现在,当您创建Uber jar时,由于处理程序文件的位置完全相同,因此一个spring.handler文件最终将覆盖其他文件,您会看到所看到的错误.这里描述了一些潜在的修复程序,其中建议了一些创建可执行jar的替代方法:

To clarify this a little more, if you are using context name space say - context:property-placeholder-configurer, the information about how to parse this namespace is using a spring.handlers file in spring-context.jar!:/META-INF/spring.handlers file, a similar file is present in other spring jar files for other custom namespaces support. Now, when you create the Uber jar, since the location of the handler file is exactly the same, one spring.handler file will end up overwriting the others, and you see the error that you are seeing. Some potential fixes are described here, where some alternate ways of creating the executable jar is suggested:

如何使用Maven创建基于Spring的可执行jar?

这篇关于无法找到Spring NamespaceHandler错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆