Is is possible to inject JSF Managed Bean into an EJB? I have injected JSF Managed Beans in to another JSF Managed Bean as a @ManagedProperty. But when I do the same to the EJB, I get a null point exception.
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- How do I delay JMS Message sending?
- PrimeFaces block UI does not work when the compone
- Something like EJB wiring in Spring for non EJB
相关文章
- @Singleton @Startup @PostConstruct method guarante
- Is it possible to destroy a CDI scope?
- The JavaEE 8 Tutorial, deploy failed on hello1 pro
- Inject producer method that returns String CDI
- Why does Google Chrome NOT use cached pages when I
- What's the default scope for a bean created by
- How to allow numbers only using f:validateRegex
- Integrating Jetty with RESTEasy
No, that's not possible. The
@ManagedProperty
works inside@ManagedBean
classes (JSF managed beans) only. You can only use@EJB
or@Inject
to inject another EJB or a CDI managed bean (a@Named
class).However, it makes design technically no sense to inject a front-end class like a JSF or CDI managed bean in a business service class like an EJB. An EJB should be designed in such way that it can without changes be reused together a completely different front-end like JAX-RS webservice or even a plain vanilla servlet. An EJB should absolutely not have any
javax.faces.*
imports/dependencies (like as that it should not have anyjavax.ws.rs.*
norjavax.servlet.*
ones).If you intend to pass data from the JSF managed bean to an EJB, then just pass it as method argument. Such data is usually in flavor of a JPA
@Entity
or at least an ID/keyword which returns an entity.