Q:

OAuth 2.0 and Resteasy: ClassNotFoundException when WAR is inside an EAR

I'm setting up an OAuth 2.0 server using Jboss 7.1.1 and Resteasy 3.0-beta-3.
I followed the official documentation and I eventually managed to build a simple application which authenticates a user using DatabaseServerLoginModule.
The problem arises when I put the war inside an ear. When I redeploy the application, I see this error:
13:32:58,336 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.subunit."JauBM-EAR.ear"."JauBM-WEB.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."JauBM-EAR.ear"."JauBM-WEB.war".INSTALL: Failed to process phase INSTALL of subdeployment "JauBM-WEB.war" of deployment "JauBM-EAR.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018096: Error instantiating container component: org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve
    at org.jboss.as.web.deployment.WarDeploymentProcessor.getInstance(WarDeploymentProcessor.java:386)
    at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:210)
    at org.jboss.as.web.deployment.WarDeploymentProcessor.deploy(WarDeploymentProcessor.java:114)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    ... 5 more
Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve from [Module "deployment.JauBM-EAR.ear.JauBM-WEB.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at org.jboss.as.web.deployment.WarDeploymentProcessor.getInstance(WarDeploymentProcessor.java:378)
    ... 8 more

Did I miss something?

A:

I figured out what the problem was, so I decided to answer the question, in case somebody has the same issue.
The solution was to move the file jboss-deployment-structure.xml in the EAR file, and change  it according to this:
JauBM-Oauth/WebContent/WEB-INF/jboss-deployment-structure.xml (deleted)
<jboss-deployment-structure>
    <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>
</jboss-deployment-structure>

EAR/META-INF/jboss-deployment-structure.xml (created)
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <sub-deployment name="JauBM-Oauth.war">
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jaxrs" services="import"
                export="true" />
            <module name="org.jboss.resteasy.resteasy-jackson-provider"
                services="import" export="true" />
            <module name="org.jboss.resteasy.skeleton-key" export="true" />
        </dependencies>
    </sub-deployment>
</jboss-deployment-structure>

