Java 无法找到XML架构命名空间(JMS)的Spring命名空间处理程序

Java 无法找到XML架构命名空间(JMS)的Spring命名空间处理程序,java,spring,jms,spring-jms,Java,Spring,Jms,Spring Jms,我试图构建一个可执行jar,运行时出现以下错误: 信息:从类路径资源[spring app.XML]加载XMLbean定义 线程“main”org.springframework.beans.factory.parsing异常:配置问题:找不到XML架构命名空间的Spring NamespaceHandler[ 有问题的资源:类路径资源[spring app.xml] 我的spring-app.xml如下: <?xml version="1.0" encoding="UTF-8"?>

我试图构建一个可执行jar,运行时出现以下错误:

信息:从类路径资源[spring app.XML]加载XMLbean定义 线程“main”org.springframework.beans.factory.parsing异常:配置问题:找不到XML架构命名空间的Spring NamespaceHandler[ 有问题的资源:类路径资源[spring app.xml]

我的spring-app.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:jms="http://www.springframework.org/schema/jms"
    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/tx 
                http://www.springframework.org/schema/tx/spring-tx.xsd
                http://www.springframework.org/schema/context
                http://www.springframework.org/schema/context/spring-context.xsd
                http://www.springframework.org/schema/jms
                http://www.springframework.org/schema/jms/spring-jms.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations">
        <list>
            <value>/etc/vtb/jndi.properties</value>
        </list>
    </property>
</bean>

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
        <props>
            <!-- prop key="java.naming.provider.url">jnp://ossprovesbjms01.gmtl.viasat.com:1099</prop-->
            <prop key="java.naming.provider.url">${java.naming.provider.url}</prop>
            <prop key="java.naming.factory.initial">${java.naming.factory.initial}</prop>
            <prop key="java.naming.factory.url.pkgs">${java.naming.factory.url.pkgs}</prop>
        </props>
    </property>
</bean>

<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref ="jndiTemplate"/>
    <property name="jndiName" value="ConnectionFactory"/>
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="pubSubDomain" value="true"/>
    <property name="deliveryPersistent" value="true"/>
    <property name="deliveryMode" value="2"/>
</bean>
<!-- Listener Asynchronous -->
<bean id="beamBalanceListener" class="com.vtblistener.BeamBalanceListener"/>

<jms:listener-container concurrency="5-10">
             <jms:listener destination="Beam_Balance" ref="beamBalanceListener"/>
</jms:listener-container>

/etc/vtb/jndi.properties
${java.naming.provider.url}
${java.naming.factory.initial}
${java.naming.factory.url.pkgs}

我的pom如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.viasat.nbn.nms</groupId>
<artifactId>vtb-hornetq-listener</artifactId>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>vtb-hornetq-listener</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <hornetq.version>2.3.13.Final</hornetq.version>
    <VTB_CONFIG_DIR>/etc/viasat/vtb/</VTB_CONFIG_DIR>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.3</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hornetq</groupId>
        <artifactId>hornetq-commons</artifactId>
        <version>${hornetq.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hornetq</groupId>
        <artifactId>hornetq-core-client</artifactId>
        <version>${hornetq.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hornetq</groupId>
        <artifactId>hornetq-jms-client</artifactId>
        <version>${hornetq.version}</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.naming</groupId>
        <artifactId>jnpserver</artifactId>
        <version>5.0.3.GA</version>
    </dependency>
    <!-- logback -->
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.0.13</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.13</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.vtblistener.VtbConsumer</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.vtblistener.VtbConsumer</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <finalName>vtb-hornetq-listener</finalName>
</build>

4.0.0
com.viasat.nbn.nms
大黄蜂窃听器
1.0.1
罐子
大黄蜂窃听器
UTF-8
2.3.13.最终版本
/etc/viasat/vtb/
朱尼特
朱尼特
3.8.1
测试
公用记录
公用记录
1.1.3
org.springframework
春季aop
4.0.1.1发布
org.springframework
春季asm
3.1.4.1发布
org.springframework
春豆
4.0.1.1发布
org.springframework
spring上下文
4.0.1.1发布
org.springframework
弹簧芯
4.0.1.1发布
org.springframework
弹簧式
4.0.1.1发布
org.springframework
SpringJDBC
4.0.1.1发布
org.springframework
SpringJMS
4.0.1.1发布
org.springframework
春季甲虫
4.0.1.1发布
org.springframework
德克萨斯州春季
4.0.1.1发布
org.springframework
弹簧网
4.0.1.1发布
org.springframework
SpringWebMVC
4.0.1.1发布
org.hornetq
大黄蜂公地酒店
${hornetq.version}
org.hornetq
大黄蜂核心客户
${hornetq.version}
org.hornetq
hornetqjms客户端
${hornetq.version}
org.jboss.naming
jnpserver
5.0.3.GA
回写
回溯堆芯
1.0.13
回写
回归经典
1.0.13
org.slf4j
slf4j api
1.7.5
org.apache.maven.plugins
maven编译器插件
1.6
1.6
org.apache.maven.plugins
maven jar插件
com.vtblistener.VtbConsumer
maven汇编插件
com.vtblistener.VtbConsumer
带有依赖项的jar
组装
包裹
单一的
大黄蜂窃听器

这是我添加到maven shade插件中的内容,它起到了作用。shade插件提供了附加jar文件中存在的资源(如属性和xml文件)的选项。AppendingTransformer用于普通文件。XmlAppendingTransformer用于xml文件

<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
  <resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
  <resource>META-INF/spring.schemas</resource>
</transformer>

META-INF/spring.handlers
META-INF/spring.schemas

尝试使用spring的xsd版本名称,如:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms"
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/tx 
            http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-4.0.xsd
            http://www.springframework.org/schema/jms
            http://www.springframework.org/schema/jms/spring-jms-4.0.xsd">

在另一个名称空间(util)中也有同样的问题,但这对我来说同样有效。