1

我有一个 Spring Boot Java 应用程序,它使用 Apache Camel 进行一些路由拦截和数据修改。我们有一个单独的“骆驼路线”文件(camelRoutes.xml),它定义了将要使用的骆驼路线。该文件中还有一些配置,据我所知,配置 Jolokia MBean 服务器和 Jolokia 代理。

系统对 Jolokia 配置 XML 有一些不满意的地方。我已经做了一些非常快速的谷歌搜索,似乎它被正确指定(参见https://jolokia.org/reference/html/jmx.html中的第 9.3.2 节)。这个问题以各种方式表现出来。当文件在 Eclipse 中的 XML 编辑器中打开时,相应的 XML 会以错误突出显示(尽管它没有提供有关它认为错误的信息)。更重要的是,当我尝试运行该应用程序时,它会因级联异常而失败,基本上指向配置文件中的问题。

摘自 camelRoutes.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jolokia="http://www.jolokia.org/jolokia-spring/schema/config"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
     http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     http://www.jolokia.org/jolokia-spring/schema/config http://www.jolokia.org/jolokia-spring/schema/config/jolokia-config.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
...
<context:mbean-export server="jolokiaServer" />
<jolokia:mbean-server id="jolokiaServer" />

<jolokia:agent lookupConfig="false"
    systemPropertiesMode="never">
    <jolokia:config autoStart="true" host="0.0.0.0"
        port="${jolokia.port:8778}"
        agentDescription="${jolokia.agentName:jolokia}" />
</jolokia:agent>

在 Eclipse 中,定义jolokia:mbean-server和的行会显示错误。jolokia:agent

应用程序执行时异常跟踪的一小部分:

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 85 in XML document from file [C:\Users\JO24447\workspace\RST_Service_Base\rust-service-base-rest\target\classes\rst_camel\camelRoutes.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 85; columnNumber: 45; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jolokia:mbean-server'.

有什么想法可能是错的吗?

4

1 回答 1

0

在我的情况下,原因是我使用了assembly没有合并spring.schemas文件的 Maven 插件。我切换到shader插件和模式验证工作。

于 2020-01-30T16:25:49.110 回答