[
https://jira.jboss.org/jira/browse/EJBTHREE-1813?page=com.atlassian.jira....
]
Andrew Lee Rubinger resolved EJBTHREE-1813.
-------------------------------------------
Resolution: Rejected
EJB 3.0 16.2.2:
A field of the bean class may be the target of injection. The field must not be final. By
default, the name of the field is combined with the name of the class in which the
annotation is
used and is used directly as the name in the bean's naming context. For example, a
field named
myDatabase in the class MySessionBean in the package com.acme.example would
correspond to the JNDI name java:comp/env/com.acme.example.MySession-
Bean/myDatabase. The annotation also allows the JNDI name to be specified explicitly.
So @Resource(name=[envEntryName]) should be used.
@Resource does not inject simple environment entries
----------------------------------------------------
Key: EJBTHREE-1813
URL:
https://jira.jboss.org/jira/browse/EJBTHREE-1813
Project: EJB 3.0
Issue Type: Bug
Components: core
Reporter: Andrew Lee Rubinger
Assignee: Andrew Lee Rubinger
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)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira