简体   繁体   English

用@EJB注释从属EJB bean时,JSF无法加载

[英]JSF failing to load when dependant EJB bean is annotated with @EJB

The original problem was due to mixing CDI with EJB which is kind of resolved now. 最初的问题是由于将CDI与EJB混合在一起,现在已经解决了。 But the following is the issue after using EJB annotations in place of Inject.. 但是以下是使用EJB注释代替Inject之后的问题。

======================================EDIT - New Information ============ ====================================编辑-新信息======== ====

It appears that the JSFServlet is not able to able to find ejb bean, 'tauthenticator' when loading login.xhtml. 似乎在加载login.xhtml时,JSFServlet无法找到ejb bean'tauthenticator'。 Also when i look at the jmx beans in Jboss admin console, the name is registered as 'Tauthenticator' instead of 'tauthenticator'. 另外,当我在Jboss管理控制台中查看jmx bean时,该名称被注册为“ Tauthenticator”而不是“ tauthenticator”。 i do not know whether this is an issue as the view requires managed bean 'tauthenticator' 我不知道这是否是一个问题,因为视图需要托管bean'tauthenticator'

Bean being created 正在创建的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

Partial stack trace when accessing http://localhost:8080/timesheet/login.html : 访问http:// localhost:8080 / timesheet / login.html时的部分堆栈跟踪:

javax.servlet.ServletException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
root cause

java.lang.StackOverflowError
java.lang.String.toLowerCase(String.java:2496)
javax.naming.NameImpl.toBoolean(NameImpl.java:202)
javax.naming.NameImpl.getBoolean(NameImpl.java:198)
javax.naming.NameImpl.recordNamingConvention(NameImpl.java:231)
javax.naming.NameImpl.<init>(NameImpl.java:254)
javax.naming.NameImpl.<init>(NameImpl.java:291)
javax.naming.CompoundName.<init>(CompoundName.java:168)
javax.naming.CompoundName.clone(CompoundName.java:260)
org.jnp.interfaces.NamingContext.composeName(NamingContext.java:1078)
org.jnp.interfaces.NamingContext.getAbsoluteName(NamingContext.java:1931)
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:719)
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
sun.reflect.GeneratedMethodAccessor411.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.ejb3.EJBContainer$1.invoke(EJBContainer.java:978)
$Proxy459.lookup(Unknown Source)
org.jboss.ejb3.JndiUtil.lookup(JndiUtil.java:44)

Extract of Tauthenticator Tauthenticator的提取

@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() {

Extract from login.xhtml 从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>

You are mixing CDI (through the import of javax.enterprise.context.RequestScoped ) and EJB (through javax.ejb.Stateful ) in the same bean. 您在同一bean中混合了CDI (通过javax.enterprise.context.RequestScoped的导入)和EJB (通过javax.ejb.Stateful )。 Moreover, these annotations have totally different scopes, so you should decide which scope to use. 此外,这些批注具有完全不同的范围,因此您应决定使用哪个范围。 And you should decide if you want to use an Enterprise Java Bean or a CDI bean. 然后,您应该决定要使用Enterprise Java Bean还是CDI Bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM