首页 > 解决方案 > Apache Camel 无效的命名空间处理程序

问题描述

我有一个在 Eclipse 上开发(重新设计)的应用程序。它在开发环境中运行良好。但是,当它被加载到 Tomcat 中时,它会因命名空间异常而失败:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [camel-config.xml] 
Offending resource: class path resource [spring-config.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [camel-config.xml]; nested exception is 
org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.camel.spring.handler.CamelNamespaceHandler] for namespace [http://camel.apache.org/schema/spring]: problem with handler class file or dependent class; nested excep
tion is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

我的 spring-config 和 camel-config 如下

<?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:p="http://www.springframework.org/schema/p"
    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:task="http://www.springframework.org/schema/task"
    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
   http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">

    <context:component-scan base-package="foo.bar.agent" />
    <task:annotation-driven />  
    <import resource="camel-config.xml" />
</beans>

骆驼配置.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring
            http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- enable Spring @Component scan -->
    <context:component-scan base-package="com.altegix.agent.hl7" />

    <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
        <property name="ignoreMissingLocation" value="true" />
        <property name="locations">
            <list>
                <value>classpath:default.properties</value>
                <value>file:/opt/altegix/agent/application.properties</value>
            </list>
        </property>
    </bean>

    <bean id="myhl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
        <property name="charset" value="iso-8859-1" />
        <property name="validate" value="false" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring"
        id="resultsCamelContext">
        <contextScan />
        <camel:endpoint id="hl7listener"
            uri="mina2:tcp://{{results.endpoint.server}}:{{results.endpoint.port}}?sync=true&amp;codec=#myhl7codec" />
    </camelContext>

    <context:annotation-config />

    <bean class="com.altegix.agent.hl7.HL7ListenerConfiguration" />

我不明白为什么我会收到 InvalidNamespace 异常?还有我以前从未见过的 noClassDefFoundError - 也许我错过了 Eclipse 中的一些类?

标签: springapache-camel

解决方案


推荐阅读