所以我在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。