Wildfly 10.0 - java.lang.NoClassDefFoundError: Failed to link org/jboss/resteasy/skeleton/key/as7/OAuthAuthenticationServerValve

Wildfly 10.0 - java.lang.NoClassDefFoundError: Failed to link org/jboss/resteasy/skeleton/key/as7/OAuthAuthenticationServerValve

我在 Wildfly 10.0

中遇到 http-handler 问题:org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve

我使用基于表单的身份验证设置了简单的身份验证应用程序 test/init oauth 2.0 的实现。

出于某种原因,我在部署我的应用程序时不断收到 NoClassDefFoundError,尽管安装了带有骨架密钥的模块。

这是 wildlfy 的错误 server.log:

    18:08:11,049 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "im-oauth-auth-1.0.war" (runtime-name: "im-oauth-auth-1.0.war")
18:08:11,447 WARN  [org.jboss.modules] (MSC service thread 1-8) Failed to define class org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve in Module "org.jboss.resteasy.skeleton-key:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules,/media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules/system/layers/base)): java.lang.NoClassDefFoundError: Failed to link org/jboss/resteasy/skeleton/key/as7/OAuthAuthenticationServerValve (Module "org.jboss.resteasy.skeleton-key:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules,/media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules/system/layers/base))): org/apache/catalina/LifecycleListener
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at org.wildfly.extension.undertow.deployment.UndertowHandlersDeploymentProcessor.handleJbossWebXml(UndertowHandlersDeploymentProcessor.java:94)
    at org.wildfly.extension.undertow.deployment.UndertowHandlersDeploymentProcessor.deploy(UndertowHandlersDeploymentProcessor.java:70)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

18:08:11,449 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."im-oauth-auth-1.0.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."im-oauth-auth-1.0.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "im-oauth-auth-1.0.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: Failed to link org/jboss/resteasy/skeleton/key/as7/OAuthAuthenticationServerValve (Module "org.jboss.resteasy.skeleton-key:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules,/media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules/system/layers/base))): org/apache/catalina/LifecycleListener
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at org.wildfly.extension.undertow.deployment.UndertowHandlersDeploymentProcessor.handleJbossWebXml(UndertowHandlersDeploymentProcessor.java:94)
    at org.wildfly.extension.undertow.deployment.UndertowHandlersDeploymentProcessor.deploy(UndertowHandlersDeploymentProcessor.java:70)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
    ... 5 more

18:08:11,450 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 6) WFLYCTL0013: Operation ("deploy") failed - address: ({"deployment" => "im-oauth-auth-1.0.war"}) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"im-oauth-auth-1.0.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"im-oauth-auth-1.0.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"im-oauth-auth-1.0.war\"
    Caused by: java.lang.NoClassDefFoundError: Failed to link org/jboss/resteasy/skeleton/key/as7/OAuthAuthenticationServerValve (Module \"org.jboss.resteasy.skeleton-key:main\" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules,/media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules/system/layers/base))): org/apache/catalina/LifecycleListener"}}
18:08:11,451 ERROR [org.jboss.as.server] (management-handler-thread - 6) WFLYSRV0021: Deploy of deployment "im-oauth-auth-1.0.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"im-oauth-auth-1.0.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"im-oauth-auth-1.0.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"im-oauth-auth-1.0.war\"
    Caused by: java.lang.NoClassDefFoundError: Failed to link org/jboss/resteasy/skeleton/key/as7/OAuthAuthenticationServerValve (Module \"org.jboss.resteasy.skeleton-key:main\" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules,/media/data/im_jboss/wildfly/wildfly-10.0.0.Final/modules/system/layers/base))): org/apache/catalina/LifecycleListener"}}
18:08:11,459 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment im-oauth-auth-1.0.war

这是我的 jboss-web.xml 内容:

<jboss-web>
  <security-domain>java:/jaas/commerce</security-domain>
  <http-handler>
    <class-name>org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve</class-name>
    <module>org.jboss.resteasy.skeleton-key</module>
  </http-handler>
</jboss-web>

这里是 jboss-部署-structure.xml

<deployment>
  <dependencies>
    <!--
                <module name="org.jboss.resteasy.resteasy-jaxrs" services="import"/>
                <module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>  -->
    <module name="org.jboss.resteasy.skeleton-key"/>
  </dependencies>
</deployment>

这里是{wildfly-10.0.0.Final}/modules/system/layers/base/org/jboss/resteasy/

的内容
drwxr-xr-x 44 ordo ordo 4096 sty 29 23:12 ../
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 jose-jwt/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-atom-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-cdi/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-crypto/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-jackson2-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-jackson-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-jaxb-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-jaxrs/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-jettison-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-jsapi/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-json-p-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-multipart-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-spring/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-validator-provider-11/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 resteasy-yaml-provider/
drwxr-xr-x  3 ordo ordo 4096 maj  8 17:44 skeleton-key/

任何帮助都会很棒! 提前致谢!

编辑:

根据要求,我正在添加骨架密钥目录的内容:

wildfly-10.0.0.Final/modules/system/layers/base/org/jboss/resteasy/skeleton-key/main$ ll
total 120
drwxr-xr-x 2 ordo ordo  4096 maj 11 09:59 ./
drwxr-xr-x 3 ordo ordo  4096 maj 11 09:59 ../
-rw-r--r-- 1 ordo ordo  2323 maj 11 09:59 module.xml
-rw-r--r-- 1 ordo ordo 53934 maj 11 09:59 skeleton-key-as7-3.0.16.Final.jar
-rw-r--r-- 1 ordo ordo 52383 maj 11 09:59 skeleton-key-core-3.0.16.Final.jar

以及module.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2010, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<module xmlns="urn:jboss:module:1.1" name="org.jboss.resteasy.skeleton-key">
    <resources>
        <resource-root path="skeleton-key-as7-3.0.16.Final.jar"/>
        <resource-root path="skeleton-key-core-3.0.16.Final.jar"/>
        <!-- Insert resources here -->
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.servlet.api"/>
        <module name="javax.security.auth.message.api"/>
        <module name="javax.security.jacc.api"/>
        <module name="org.jboss.as.web"/>
        <module name="javax.ws.rs.api"/>
        <module name="org.picketbox"/>
        <module name="org.codehaus.jackson.jackson-core-asl"/>
        <module name="org.codehaus.jackson.jackson-jaxrs"/>
        <module name="org.codehaus.jackson.jackson-mapper-asl"/>
        <module name="org.codehaus.jackson.jackson-xc"/>
        <module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
        <module name="org.jboss.resteasy.resteasy-jaxrs" services="import"/>
        <module name="org.jboss.logging"/>
        <module name="org.jboss.resteasy.jose-jwt"/>
        <module name="org.bouncycastle"/>
    </dependencies>
</module>

看来skeleton-key模块没有移植到undertow,这是我使用的wildfly 10的默认设置。

我想我已经找到了解决办法。
添加文件jboss-部署-structure.xml
内容如下:

<?xml version="1.0" encoding="UTF-8"?>
 <jboss-deployment-structure>
    <deployment>
        <exclusions>
            <module name="org.jboss.resteasy.skeleton-key" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

最后一步,将此 jar 添加到您的项目中。