Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-889

@Inject fails for EJBs not defined in web module

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 1.1.0.Beta2
    • Resolution
    • None
    • Hide

      Failing case:

      Create EAR archive with 1 EJB module and 1 WEB module.
      Add a Stateless session bean in EJB module.
      Enable CDI for WEB module, create a @RequestScoped bean like given in description.
      Inject bean in web servlet, map servlet to some URL.
      Deploy EAR and request URL.
      Results in given exception.

      Success case:

      Move EJB from EJB module to WEB module.
      Restart server and request URL.
      Does not results in exception and EJB being injected as expected.

      Show
      Failing case: Create EAR archive with 1 EJB module and 1 WEB module. Add a Stateless session bean in EJB module. Enable CDI for WEB module, create a @RequestScoped bean like given in description. Inject bean in web servlet, map servlet to some URL. Deploy EAR and request URL. Results in given exception. Success case: Move EJB from EJB module to WEB module. Restart server and request URL. Does not results in exception and EJB being injected as expected.

    Description

      Trying to inject an EJB bean using @Inject into a bean in a web module fails when the EJB in question is defined in an EJB module. Injecting an EJB that is defined in the web module works as expected.

      The exception raised is:

      org.jboss.weld.exceptions.CreationException: WELD-000079 Could not find the EJB in JNDI

      Example:

      @RequestScoped
      public class MyBeanA {

      @Inject
      private UserDAOA userDAO; // EJB defined in EJB module, fails

      public void test()

      { userDao.getByID(...); }

      }

      @RequestScoped
      public class MyBeanB {

      @Inject
      private UserDAO userDAOB; // EJB defined in (same) web module, works

      public void test() { userDao.getByID(...); }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            henk53_jira henk de boer (Inactive)
            Votes:
            6 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: