WildFly:从 Wildfly 模块访问 war/lib 类

WildFly: Access war/lib classes from wildfly modules

我有 wildfly 创建的 spring 模块和 myApp.ear, myApp.ear 包含 myApp.war 并且里面有 WEB-INF/lib/commons-pool2-2.4.2.jar 和 WEB-INF/lib/myApp-core.jar 在 myApp-core.jar 我有 spring 上下文,其中有:

<bean id="myAppPoolTargetSource" class="org.springframework.aop.target.CommonsPool2TargetSource">
    <property name="targetBeanName" value="dataPostComponentTarget" />
    <property name="maxSize" value="${POOL_POST_SIZE}" />
    <property name="maxIdle" value="${POOL_POST_SIZE}"/>
    <property name="minIdle" value="${POOL_POST_SIZE}"/>
</bean>

我有 jboss 部署描述符 jboss-deployment-structure.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module export="true" meta-inf="export" name="org.springframework.spring"/>
            <module export="true" meta-inf="export" name="org.apache.cxf"/>
            <module export="true" meta-inf="export" name="org.apache.cxf.impl"/>
            <module export="true" name="javax.orb.api"/>
            <module export="true" name="org.apache.commons.beanutils"/>
        </dependencies>
        <exclude-subsystems>
            <subsystem name="logging"/>
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

我还在 wildfly 中为 spring 创建了模块,这里是 module.xml:

<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.5" name="org.springframework.spring">
    <resources>

        <resource-root path="spring-beans-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-core-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-aop-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-expression-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-web-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-webmvc-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-jms-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-messaging-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-tx-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-context-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-context-support-4.3.14.RELEASE.jar"/>
        <resource-root path="spring-oxm-4.3.14.RELEASE.jar"/>
    </resources>

    <dependencies>
        <module name="org.apache.commons.logging"/>
        <module name="org.jboss.vfs" />
        <module name="org.jboss.msc" />
    <module name="javaee.api"/>
    </dependencies>
</module>

对于我的其他耳朵来说,它是完美的,但对于这只耳朵来说,它是失败的:

Caused by: java.lang.NoClassDefFoundError: Failed to link org/springframework/aop/target/CommonsPool2TargetSource (Module "org.springframework.spring" from local module loader @51931956 (finder: local module finder @2b4a2ec7 (roots: C:\wildfly-11.0.0.Final\modules,C:\wildfly-11.0.0.Final\modules\system\layers\base))): org/apache/commons/pool2/PooledObjectFactory 

原因完全清楚 spring 模块 class 加载器无法在 myApp 中看到 classes。war/lib 但我如何才能使它们可见? 为了使模块对其他部署可见,我可以在 dependencie 中添加 "export=true",但它如何朝不同的方向发展?

更新

我尝试将池库 jar 移动到 .ear/lib 并设置

<ear-subdeployments-isolated>false</ear-subdeployments-isolated>

在部署描述符中,但没有效果

池库需要是模块的一部分。 org.springframework.spring 将无法在您的部署中看到库。您可以将 commons-pool2-2.4.2.jar 库添加到 org.springframework.spring 或创建一个新模块并让 org.springframework.spring 模块依赖它。