Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-1813

@Resource does not inject simple environment entries

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • None
    • core
    • None
    • Workaround Exists
    • Hide

      Specify "injection-target" in XML within env-entry.

      Show
      Specify "injection-target" in XML within env-entry.

    Description

      Given:

      <!-- Override the one-way hash MessageDigest algorithm -->
      <env-entry>
      <env-entry-name>messageDigestAlgorithm</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>SHA</env-entry-value>
      </env-entry>

      All that should be required for injection is @Resource upon a field of same name within the bean class:

      @Resource
      private String messageDigestAlgorithm;

      Spec 16.4.1.1:

      The Bean Provider uses the Resource annotation to annotate a field or method of the bean class as a
      target for the injection of a simple environment entry. The name of the environment entry is as described
      in Section 16.2.2; the type is as described in Section 16.4.

      WARN message in logs is:

      17:37:00,963 WARN [ResourceHandler] Not injecting messageDigestAlgorithm, no matching enc injector env/org.jboss.ejb3.examples.ch05.encryption.EncryptionBean/messageDigestAlgorithm found

      ENC is:

      +- EJBContext (class: javax.ejb.EJBContext)
      +- TransactionSynchronizationRegistry[link -> java:TransactionSynchronizationRegistry] (class: javax.naming.LinkRef)
      +- UserTransaction (class: org.jboss.ejb3.tx.UserTransactionImpl)
      +- env (class: org.jnp.interfaces.NamingContext)

      +- messageDigestAlgorithm (class: java.lang.String)
      +- ciphersPassword (class: java.lang.String)
      +- org.jboss.ejb3.examples.ch05.encryption.EncryptionBean (class: org.jnp.interfaces.NamingContext)
        +- context[link -> java:comp/EJBContext] (class: javax.naming.LinkRef)
      +- ORB[link -> java:/JBossCorbaORB] (class: javax.naming.LinkRef)

      Attachments

        Activity

          People

            arubinge@redhat.com Andrew Rubinger (Inactive)
            arubinge@redhat.com Andrew Rubinger (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: