Wildfly 10.1 CDI / WELD不适用于@Any(在模块中引用jar内部的war)

时间:2017-09-01 12:43:48

标签: java jboss classloader cdi wildfly-10

我的本​​地实例interFaces(我的java war web-app 中的)没有从引用的“cdi-able(thejarwithbeansxml.jar)”(beans.xml)jar中注入来自我的jboss-deployment-structure.xml(参考模块)。

请参阅以下配置;

theapp.ear

--- META-INF - > JBoss的部署-structure.xml

---一堆ejb的

---一堆战争

--- webapp.war (请参阅模块配置)

(theapp.ear-> META-INF)中的jboss-deployment-structure.xml主体

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">

<!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry -->
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>

<deployment>
    <dependencies>
        ...
</deployment>


<sub-deployment name="webapp.war">
    <dependencies>
        <module name="com.mymoduletest1"
                meta-inf="import"
                services="import"
                slot="main"
                annotations="false"
                export="true"
                optional="false">
            <imports>
                <include-set>
                    <path name="META-INF"/>
                    <path name="META-INF/beans.xml"/>
                    <path name="META-INF/*"/>
                </include-set>
            </imports>
        </module>
</sub-deployment>
</jboss-deployment-structure>

module.xml

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.mymoduletest1">

<resources>
    <resource-root path="thejarwithbeansxml.jar"/>
</resources>

<dependencies>
    <module name="someothermodule" export="true">
        <imports>
            <include path="META-INF"/>
        </imports>
    </module>
</dependencies>
</module>

webapp.war(部署为耳朵的一部分)

具有Rest Web服务类,其中注入发生如下; //expecting to have subclasses of {IActionBase {1}}

一次又一次地阅读Wildfly文档后,我似乎遵循了所有规则,并且Wildfly支持这种类型的功能。例; Snippet from JBoss

当我创建一个驻留在webapp.war中的IActionBase子类时,没有问题。 任何建议都将不胜感激。

附加测试代码

以下代码(在webapp.war 中);

injected from module com.mymoduletest1.
@Inject
@Any
private Instance<IActionBase> interFaces;

产生以下结果(表明beans.xml可见并加载);

java.io.InputStream schemaIS = Class.forName("com.fluidattica.test.TestCrazy").getClassLoader().getResourceAsStream("META-INF/beans.xml");

            int readVal = -1;
            while((readVal = schemaIS.read()) > -1)
            {
                System.out.print((char)readVal);
            }

0 个答案:

没有答案