18

私はこのエラーを1週間近く抱えており、もうすぐ諦める準備ができています。Maven2を使用してBIGjarファイルを作成しました。以下を使用して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を削除しました.jar)

http://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdに変更 しました。

これらの変更のいずれもエラーを削除していません。

車内ファイルはに存在します

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

誰かアイデアがありますか。

4

1 に答える 1

25

発生した可能性が非常に高いのは、カスタム名前空間ハンドラー(spring.schema、spring.handlers)の場所に関するメタデータをSpringに提供するファイルが、big(uber)jarを作成したときに相互に上書きしてしまったことです。

これをもう少し明確にするために、コンテキスト名前空間を使用している場合、たとえば- context:property-placeholder-configurer、この名前空間を解析する方法に関する情報は、ファイル内のspring.handlersファイルを使用していspring-context.jar!:/META-INF/spring.handlersます。同様のファイルは、他のカスタム名前空間をサポートするために他のSpringjarファイルに存在します。 。これで、Uber jarを作成すると、ハンドラーファイルの場所がまったく同じになるため、1つのspring.handlerファイルが他のファイルを上書きしてしまい、表示されているエラーが表示されます。ここでは、いくつかの潜在的な修正について説明します。ここでは、実行可能jarを作成するいくつかの代替方法が提案されています。

MavenでSpringベースの実行可能jarを作成するにはどうすればよいですか?

于 2013-02-27T12:05:53.280 に答える