【问题标题】:jmxagent throwing saxparse exception when added in camel contextjmxagent 在骆驼上下文中添加时抛出 saxparse 异常
【发布时间】:2019-05-08 10:53:19
【问题描述】:

我在camelcontext.xml中添加了下面的代码sn-p

<jmxAgent id="agent" createConnector="true" />

但上面添加的代码在 Jboss 实例中部署时给了我以下异常:

------------------

>  nested exception is
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 64 in XML document from class path resource
> [META-INF/spring/camel-routes/camel-context.xml] is invalid; nested
> exception is org.xml.sax.SAXParseException; lineNumber: 64;
> columnNumber: 49; cvc-complex-type.2.4.a: Invalid content was found
> starting with element 'jmxAgent'. One of
> '{"http://camel.apache.org/schema/spring":threadPoolProfile,
> "http://camel.apache.org/schema/spring":threadPool,
> "http://camel.apache.org/schema/spring":endpoint,
> "http://camel.apache.org/schema/spring":dataFormats,
> "http://camel.apache.org/schema/spring":transformers,
> "http://camel.apache.org/schema/spring":validators,
> "http://camel.apache.org/schema/spring":redeliveryPolicyProfile,
> "http://camel.apache.org/schema/spring":onException,
> "http://camel.apache.org/schema/spring":onCompletion,
> "http://camel.apache.org/schema/spring":intercept,
> "http://camel.apache.org/schema/spring":interceptFrom,
> "http://camel.apache.org/schema/spring":interceptSendToEndpoint,
> "http://camel.apache.org/schema/spring":restConfiguration,
> "http://camel.apache.org/schema/spring":rest,
> "http://camel.apache.org/schema/spring":route}' is expected.
>         at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
> [spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
>         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
> [spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
>         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
> [spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]

以下是我完整的camelcontext.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:camel="http://camel.apache.org/schema/spring"
          xmlns:context="http://www.springframework.org/schema/context"
            xmlns:util="http://www.springframework.org/schema/util"
         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/util     
                http://www.springframework.org/schema/util/spring-util-3.0.xsd
               http://www.springframework.org/schema/context  
               http://www.springframework.org/schema/context/spring-context.xsd ">

    <context:annotation-config />
    <import resource="file:${FIS_HOME}/CONFIG/database-context.xml" />
    <import resource="file:${FIS_HOME}/Scheduler/job-scheduer.xml" />
    <import resource="file:${FIS_HOME}/Process/processor-context.xml" />
    <!-- End : Files import to camel context-->
    <camelContext xmlns="http://camel.apache.org/schema/spring" 
 trace="true" streamCache="true" lazyLoadTypeConverters="true" id="main">
        <properties>
<property key="CamelLogEipName" value="com.mycode.route"/>
        </properties>

<propertyPlaceholder id="properties" location="file:${FIS_HOME}/Config/routes.properties"                            xmlns="http://camel.apache.org/schema/spring"/>

 <routeContextRef ref="manager-job-routes" />
<routeContextRef ref="report-routes" />

<threadPoolProfile id="DefaultThreadPoolProfile" defaultProfile="true"
poolSize="70" maxPoolSize="100" maxQueueSize="-1" allowCoreThreadTimeOut="false" rejectedPolicy="CallerRuns"/>

 <jmxAgent id="agent" createConnector="true" statisticsLevel="RoutesOnly"/>

</camelContext>
</beans>`

我使用的骆驼版本是 2.23.2。我也对骆驼有以下依赖:

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jmx</artifactId>
        <version>${camel.version}</version>
    </dependency>`

我换了骆驼弹簧xsds,但问题仍然存在

【问题讨论】:

    标签: java jboss xsd apache-camel xsd-validation


    【解决方案1】:

    我认为问题在于jmxAgent 标签的顺序。将 jmxAgent 标签放在 camelContext 标签的开头。检查camel-spring.xsd你会发现

      <xs:extension base="tns:abstractCamelContextFactoryBean">
        <xs:sequence>
          ....
          <xs:element minOccurs="0" ref="tns:packageScan"/>
          <xs:element minOccurs="0" ref="tns:contextScan"/>
          <xs:element minOccurs="0" ref="tns:streamCaching"/>
          <xs:element minOccurs="0" ref="tns:jmxAgent"/>
          .....
          <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:routeContextRef"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:restContextRef"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:threadPoolProfile"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:threadPool"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:endpoint"/>
          .....
       </xs:sequence>
      </xs:extension>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-27
      相关资源
      最近更新 更多