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

时间:2018-05-16 04:56:24

标签: spring module wildfly classloader

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

<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>

此外,我在springfly中为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模块类加载器的原因是看不到myApp.war / lib中的类但我怎么能让它们可见? 为了使模块可见其他部署我可以添加&#34; export = true&#34;在依赖,但它如何在不同的方向?

更新

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

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

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

1 个答案:

答案 0 :(得分:2)

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