使用CDI无法在嵌入式glassfish上注入jndi字符串资源

时间:2013-06-20 12:59:39

标签: cdi glassfish-embedded

所以我在domain.xml中创建了一个自定义引用

<custom-resource res-type="java.lang.String" jndi-name="jndi/myResource" factory-class="org.glassfish.resources.custom.factory.PrimitivesAndStringFactory">
        <property name="value" value="myValue"/>
</custom-resource>

并在@ApplicationScoped bean中通过@Resource(lookup = "jndi/myResource")引用它。

我也使用endorsed目录启动服务器(包含endorsed-api.jar)。仍然当我引用资源时,它不会注入并抛出空值。

看起来所有设置都正确,不知道我在这里缺少什么。 是的,我在Meta-inf目录中也有beans.xml。

0 个答案:

没有答案