javax.servlet.ServletException:WFLYWELD0044:将资源注入CDI托管bean时出错。无法找到名为的资源。 。

时间:2017-03-23 14:45:04

标签: java ejb wildfly-10

错误发生在WildFly 10容器中。 整个错误看起来像:

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NameNotFoundException: env/com.maggioni.Bean.InfoBean/infoCreator -- service jboss.naming.context.java.module.B77.EJBStatefulBean-Bidder-Demo-web.env."com.maggioni.Bean.InfoBean".infoCreator
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
a...

[0m[31m13:45:26,716 ERROR [io.undertow.request] (default task-8) UT005023: Exception handling request to /web/infobean.jsf: javax.servlet.ServletException: WFLYWELD0044: Error injecting resource into CDI managed bean. Can't find a resource named java:comp/env/com.maggioni.Bean.InfoBean/infoCreator

Infobean.jsf正在注入如下的EJB:

@Named("infobean")
@SessionScoped
public class InfoBean implements Serializable{     
    private static final long serialVersionUID = 1L;

    @EJB
    private InfoCreator infoCreator;

    public String getInfo() {
        return infoCreator.getInfo();
    }
}

和EJB Infocreator看起来像

@Stateful 
public class InfoCreator implements InfoInterface{

    @Override
    public String getInfo() {
       return "Info";
    }
}

如果您想了解更多详情,请与我们联系,我不太确定需要在此发布什么内容。

GitHub存储库是here

1 个答案:

答案 0 :(得分:0)

首先,为什么要尝试将有状态EJB注入CDI bean? 鉴于您发布的代码,我认为没有任何理由使用EJB(对于有状态的更少)。

只需删除@Stateful注释并将其注入:

select *
from table_name