Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当依赖EJB bean被@EJB注释时,JSF无法加载_Java_Ejb - Fatal编程技术网

Java 当依赖EJB bean被@EJB注释时,JSF无法加载

Java 当依赖EJB bean被@EJB注释时,JSF无法加载,java,ejb,Java,Ejb,最初的问题是由于将CDI与EJB混合在一起而造成的,现在已经解决了。但是在使用EJB注释代替Inject之后,出现了以下问题 =======================================================编辑-新信息============ 在加载login.xhtml时,JSFServlet似乎无法找到ejb bean“tauthenticator”。另外,当我在Jboss管理控制台中查看jmx bean时,名称注册为“Tauthenticator”,而不是“T

最初的问题是由于将CDI与EJB混合在一起而造成的,现在已经解决了。但是在使用EJB注释代替Inject之后,出现了以下问题

=======================================================编辑-新信息============

在加载login.xhtml时,JSFServlet似乎无法找到ejb bean“tauthenticator”。另外,当我在Jboss管理控制台中查看jmx bean时,名称注册为“Tauthenticator”,而不是“Tauthenticator”。我不知道这是否是一个问题,因为视图需要托管bean“tauthenticator”

正在创建的Bean

21:09:42,602 INFO  [org.jboss.ejb3.nointerface.impl.jndi.AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:Tauthenticator
        Tauthenticator/no-interface -> EJB3.1 no-interface view
[org.jboss.ejb3.nointerface.impl.jndi.AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:TusersBean
        TusersBean/no-interface -> EJB3.1 no-interface view
访问时的部分堆栈跟踪:

拉紧器提取物

@StatefulTimeout(unit=TimeUnit.MINUTES, value=500) @Stateful
@Named("tauthenticator")  public class Tauthenticator {
@Getter @Setter private String username;
@Getter @Setter private String password;
@Getter @Setter boolean loggedIn = false;   
@Getter @Setter Tusers users = null;
@EJB TusersBean usersBean;
@Inject private Event<ExceptionToCatch> catchEvent;

public String authenticate() {
从login.xhtml中提取

<h:outputLabel for="username" style="font-weight:bold;">#{' '}Username</h:outputLabel>
<p:inputText id="username" value="#{tauthenticator.username}"/>
<h:outputLabel for="password" style="font-weight:bold;">#{' '}Password</h:outputLabel>
<p:password id="password" value="#{tauthenticator.password}" feedback="false"/>
<h:outputLabel>#{''}</h:outputLabel>

您通过在同一个bean中导入javax.enterprise.context.RequestScoped和通过javax.EJB.Stateful导入EJB来混合CDI。此外,这些注释具有完全不同的作用域,因此您应该决定使用哪个作用域。您应该决定是使用企业Java Bean还是CDIBean。

能否显示包含导入的Bean代码?谢谢您的回答。从您的解释和对其他文档的公平阅读来看,我相信当在另一个类中作为依赖项引用时,由无状态、有状态或单例标识的ejb,建议使用“@ejb”而不是“@Inject”。我尝试使用这个原则,并在我的应用程序中跨类进行更改。现在,当我部署打包为war的应用程序时,它部署得很好。Jboss报告用ejb注释标记的bean被创建并注册到JNDI。但当我启动UI时,会出现stackoverflow异常。我将在下面用详细信息和代码进行解释,因为我在这里输入的字符不多,所以我会将详细信息添加到原始帖子中。。。
<h:outputLabel for="username" style="font-weight:bold;">#{' '}Username</h:outputLabel>
<p:inputText id="username" value="#{tauthenticator.username}"/>
<h:outputLabel for="password" style="font-weight:bold;">#{' '}Password</h:outputLabel>
<p:password id="password" value="#{tauthenticator.password}" feedback="false"/>
<h:outputLabel>#{''}</h:outputLabel>