Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-1901

@Inject not working for EJB module

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.0.1
    • 7.0.2
    • None
    • None

    Description

      Seems like CDI is not activated for an EJB module with only @Stateless EJBs. The console also has the warning:

      The application [ejb-1.0-SNAPSHOT] uses @Inject but CDI is not enabled. Maybe youd need to add a beans.xml file.
      

      However the CDI 1.1 spec states that (section 12.1 Bean archives):

      An implicit bean archive is any other archive which contains one or more bean classes with a bean defining annotation, or one or more session beans.

      I've created a simple maven project that reproduces the problem. It has one EJB module and one web module. The web module uses @EJB to get an Stateless local interface view bean from the EJB module, which in turn tries to @Inject another bean from the same EJB module, but fails.

      Steps:

      • Download the tomee-ejb-@inject-bug.zip
      • extract and run mvn package
      • Deploy the ear/target/ear-1.0-SNAPSHOT.ear file to TomEE 7.0.1
      • Access SEVER_URL/ear-1.0-SNAPSHOT/ outputs "some null", while expected would be a non null value. GlassFish 4.1 and WildFly 10 output a non null value for the same application.

      Let me know if there are any more questions.

      Attachments

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            tonis.pool@gmail.com Tõnis Pool
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: