是什么导致 "Unexpected element" 在 JBoss 配置中抛出 XMLStreamValidationException?

What causes this "Unexpected element" that throws XMLStreamValidationException in JBoss config?

我正在尝试将一些软件从 JBoss 5 迁移到 JBoss 7。我被卡住了,因为我的部署失败,出现以下异常。请记住,该软件在 JBoss 5 中运行,所以任何不工作的地方应该是因为 JBoss 5/7 之间的差异,我假设。

有问题的行(异常中指出的第 12 行)如下:

<application-policy xmlns="urn:jboss:security-beans:1.0" name="MyProjectDatabaseLogin">

errors/exceptions 是:

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."myear.ear".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myear.ear".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "myear.ear"
    [stack trace omitted]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYPOJO0038: Exception while parsing POJO descriptor file: "/content/myear.ear/META-INF/myproject-auth-jboss-beans.xml"
    [stack trace omitted]
Caused by: org.projectodd.vdx.core.XMLStreamValidationException: ParseError at [row,col]:[12,4]
Message: ParseError at [row,col]:[12,4]
Message: WFLYCTL0198: Unexpected element '{urn:jboss:security-beans:1.0}application-policy' encountered
    [stack trace omitted]

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "myear.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"myear.ear\".PARSE" => "WFLYSRV0153: Failed to process phase PARSE of deployment \"myear.ear\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYPOJO0038: Exception while parsing POJO descriptor file: \"/content/myear.ear/META-INF/myproject-auth-jboss-beans.xml\"
    Caused by: org.projectodd.vdx.core.XMLStreamValidationException: ParseError at [row,col]:[12,4]
Message: ParseError at [row,col]:[12,4]
Message: WFLYCTL0198: Unexpected element '{urn:jboss:security-beans:1.0}application-policy' encountered"}}

为什么 application-policy(或它的 xmlns 值)在这里出乎意料?是什么导致了这个异常?


我不得不手动输入上面的 xml 行和 errors/exceptions,所以可能有一些拼写错误实际上并没有出现在原文中,但不会导致问题,尽管我在这里重读了我的问题好几次,我不认为我打错了上面的内容。

我最终发现这些可配置项不再应该在同一个文件中。此信息现在应该位于服务器的配置文件中,因此您可能会将其放入 domain.xml 文件或 standalone.xml 文件中。

这是一个安全应用策略,所以这个标签的内容现在进入 <security-domain> 标签的 <security-domains> 部分。

所以它会像下面这样。请注意,<application-policy ...> 现在是 <security-domain ...>,并且在 <security-domains> 之内。此外,我之前的安全应用程序策略中有两个 <login-module>,但如果使用新的鞘翅安全系统,则安全域中只允许使用 1 个 <login-module> 标记...

...
    <security-domains> <!-- Search for this in the file and put the migrated part into here -->
        <security-domain name="MySecurityDomain">
            ... all the stuff that used to be in the security application policy
            ... note that some of the stuff you put in here might need to change depending on the security system used
        </security-domain>
    </security-domains>
...