私はroo 1.2.2で起動した小さなSpringプロジェクトを持っています
Eclipse Juno 内でメイン クラスを問題なく実行できます。しかし、でビルドされた JAR ファイルを実行しようとするとmvn package
、次のエラーが発生します。
Exception in thread "main"
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace [http://www.springframework.org/schema/tx]
Offending resource: class path resource [META-INF/spring/applicationContext.xml]
次の構成で、Maven shade プラグインを使用して uber JAR をビルドしています。
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.xyz.watcher.WatcherMain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
...
私が持っている pom.xml プロパティ<spring.version>3.1.2.RELEASE</spring.version>
で、依存関係の1つは次のとおりです。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
アプリケーション コンテキスト ヘッダーは次のとおりです。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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">
私のメインプログラムには次のものがあります。
String[] springConf = new String[] { "META-INF/spring/applicationContext.xml",
"META-INF/spring/watcher.xml" };
BeanFactory appContext = new ClassPathXmlApplicationContext(springConf);
入力するmvn package
と取得します
[INFO] Building jar: /home/stivlo/workspace/monitor/target/monitor-0.1.0.BUILD-SNAPSHOT.jar
[INFO] --- maven-shade-plugin:1.7.1:shade (default) @ monitor ---
...
[INFO] Including org.springframework:spring-tx:jar:3.1.2.RELEASE in the shaded JAR.
欠けているものと、JAR を実行できるようにビルドを修正する方法を誰でも提案できますか?