WildFly: Access war/lib classes from wildfly modules

I have wildfly with created spring module and myApp.ear, myApp.ear contain myApp.war and inside there WEB-INF/lib/commons-pool2-2.4.2.jar and WEB-INF/lib/myApp-core.jar inside myApp-core.jar i have spring context which have:

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

And i have jboss deployment descriptor 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>

Also i have created module in wildfly for spring here it is 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>

For other my ear it is works perfect but for this one it is fail:

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 

The reason completely clear spring module class loader cant see classes inside myApp.war/lib but how i can make them visible? to make module visible for other deployment i could add "export=true" in dependencie, but how it make in different direction?

UPDATE

I have tried to move pool library jar into .ear/lib and set

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

in deployment descriptor, but no effect

1 answer

  • answered 2018-05-16 23:26 James R. Perkins

    The pool library needs to be part of the module. The org.springframework.spring won't be able to see libraries in your deployment. You can either add the commons-pool2-2.4.2.jar library to the org.springframework.spring or create a new module and have the org.springframework.spring module depend on it.