首页 文章

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

提问于
浏览
1

我有创建了spring模块的wildfly和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>

我也在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中的类,但我怎么能让它们可见?为了使模块可见于其他部署,我可以在依赖项中添加“export = true”,但它如何在不同的方向上进行?

UPDATE

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

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

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

1 回答

  • 2

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

相关问题