gpt4 book ai didi

java - jmxagent 在添加到 Camel 上下文中时抛出 saxparse 异常

转载 作者:行者123 更新时间:2023-12-02 05:52:26 24 4
gpt4 key购买 nike

我在我的camelcontext.xml中添加了以下代码片段

<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>`

我使用的camel版本是2.23.2。我还对 Camel 有以下依赖:

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

我更改了camel spring xsds,但问题仍然存在

最佳答案

我认为问题在于 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>

关于java - jmxagent 在添加到 Camel 上下文中时抛出 saxparse 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56039076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com