EJB Injection in JSF Managed Beans

While trying to create a simple prototype for an application which uses JSF, EJB 3 and JPA, I decided to implement the suggestions from the article: Using an EJB Session Bean as a Model Facade.

I was particularly interested in injecting my EJBs to my JSF Managed Beans (the article mentioned that it should be possible to do this kind of injection with JSF Managed Beans and Servlets).

public class CatalogServlet extends HttpServlet {

@EJB private CatalogFacade cf;

// some variables and methods
}

I tried using JBoss 4 since it already had lots of available documentation regarding EJB 3 only to find out that this feature is not yet supported.

I tried switching to JBoss 5 Beta 4 but the error was the same.

16:16:31,765 ERROR [JBossInjectionProvider] Injection failed on managed bean.
javax.naming.NameNotFoundException: “Name of your Managed Bean goes here” not bound

Hmm, I should probably try this with GlassFish one of these days.

Recommended books:

0131738860 1933988347 1847192602

Advertisements

3 Comments »

  1. Armen said

    JBoss 4.2.2 does not support @EJB annotation, because Jboss used Tomcat 5.5 that does not support jdk 1.5. JBoss 5 beta supported tomcat 6 and jdk 1.5, but it is not work properly. Use GlassFish or JBoss 4.2. 2 and instead @EJB use lookup.

  2. Coudy said

    Have you ever tried with glassfish because it would be useful for me?
    Thanks

  3. dayg said

    Sorry but I did not manage to try it out in GlassFish, but I’m guessing that these resources should be able to give you an idea of what to expect:

    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#mappingRemoteejbdependency

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: