【问题标题】:CDI 1.1 with annotated discovery mode is not working on Weblogic 12.2带注释发现模式的 CDI 1.1 不适用于 Weblogic 12.2
【发布时间】:2021-05-06 10:19:24
【问题描述】:

当 bean-discovery-mode 从“all”更改为“annotated”时,CDI bean 不工作。

javax.el.PropertyNotFoundException: //C:/Users/XYZ/Documents/_java/JavaWeb/src/main/webapp/test.xhtml @22,75 value="#{testBean.prop1}": 目标不可达,标识符 'testBean' 解析为空 com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) 在 com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95) 在 javax.faces.component.UIInput.getConvertedValue(UIInput.java:1045) 在 javax.faces.component.UIInput.validate(UIInput.java:975) 在 javax.faces.component.UIInput.executeValidate(UIInput.java:1248) 截断。请参阅日志文件以获取完整的堆栈跟踪原因: javax.el.PropertyNotFoundException:目标不可达,标识符 'testBean' 解析为空 com.sun.el.parser.AstValue.getTarget(AstValue.java:173) 在 com.sun.el.parser.AstValue.getType(AstValue.java:85) 在 com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201) 在 org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93) 在 org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93) 截断。查看完整堆栈跟踪的日志文件

beanx.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
                           http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    version="1.1" bean-discovery-mode="annotated">
</beans>

TestBean.java 已经用 RequestScoped 进行了注解。

package bean;

@javax.inject.Named()
@javax.enterprise.context.RequestScoped
public class TestBean implements java.io.Serializable {
    static final long serialVersionUID = 1L;
    static final org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();

    private String uid;
    private String prop1;

    @javax.annotation.PostConstruct
    public void PostConstruct() {
        this.uid = String.valueOf(System.currentTimeMillis());
        logger.debug("uid: {}", this.uid);
        logger.debug("prop1: {}", this.prop1);
    }

    @javax.annotation.PreDestroy
    public void PreDestroy() {
    }

    public void doAction() {
        logger.debug("uid: {}", this.uid);
        logger.debug("prop1: {}", this.prop1);
    }

    public String getProp1() {
        return prop1;
    }

    public void setProp1(String prop1) {
        this.prop1 = prop1;
    }

}

test.xhtml

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
    <title>Testing</title>
</h:head>

<h:body>
    <ui:debug />

    <h:form id="form_1">
        <h:messages id="msg" errorClass="errorClass" infoClass="infoClass"
            layout="list" />
        <div>
            prop_1:
            <h:inputText id="prop_1" title="inputText" value="#{testBean.prop1}" />
        </div>
        <h:commandButton value="doAction" action="#{testBean.doAction}" />
    </h:form>
</h:body>
</html>

想知道“带注释的”bean-discovery-mode 是如何工作的,我想念什么?

【问题讨论】:

    标签: java cdi weblogic12c


    【解决方案1】:

    也许将 beans.xml, bean-discovery-mode="annotated" 更改为 bean-discovery-mode="none" 会有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-21
      • 2015-06-14
      • 1970-01-01
      • 2012-12-27
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多